locked
File Upload To A Shared Folder RRS feed

  • Question

  • Hi ppl,

    Is there any way to upload a file to a shared folder on our domain network like \\server\folder\ using vb.net+asp.net?

     

    Tuesday, December 27, 2005 2:14 AM

Answers

  • To help debug, try the following

    1. The directory should be shared for this user.. Go to sharing and security and set the permissions so that this user has access

    2. The user should have write access to the folder. Go to the security tab and add explicit access to the user you are impersonating and give write access to the user..

    3. check if you are able to access the share from IE.. 

    4. If you are able to access from IE, then try doing filewebrequest from a console app.

    5. If this succeeds and still your asp.net fails, then there is a problem with impersonation.

     

    Wednesday, December 28, 2005 5:17 PM

All replies

  • hi ...

    i am using the normal filesystem from vb.net and i am able to upload to local ... but once i changed to //server/folder ...

    it prompt me some error that it is not able to access the folder...

    i was taught that i need to impersonate the identity in the web.config ... so i use the common username and password that have full access to the server ...

    but i still end up getting an access denied error

    "System.UnauthorizedAccessException: Access to the path "\\sggsgptp12ms013\IT\Shared\Yong Quan\uploadtest.zip" is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at examples.FileManager.AddFiles(String destFolder, String fileName_Start, HtmlInputFile fileUpload, Page cpage) in C:\Inetpub\wwwroot\examples\common\FileManager.vb:line 23 "

    does anyone knows the cause for this type of error?

    Wednesday, December 28, 2005 9:26 AM
  •  

     If the directories that the files reside in are available as network
    shares, then you can use the static Copy method on the File class to copy
    from one directory to another.  Just make sure you use the UNC
    representation of the path.

    Furthermore, you also have to make
    sure that you have to have write permission to that folder.

    Wednesday, December 28, 2005 11:14 AM
  • Try this and let me know if it works.

    Dim instance As New System.Net.WebClient

    instance.UploadFile(address, filename)

     

    By default, the .NET Framework supports URIs that begin with http:, https:, ftp: and file: scheme identifiers.

    You should beable to use file:and address.

    Wednesday, December 28, 2005 1:58 PM
  • To help debug, try the following

    1. The directory should be shared for this user.. Go to sharing and security and set the permissions so that this user has access

    2. The user should have write access to the folder. Go to the security tab and add explicit access to the user you are impersonating and give write access to the user..

    3. check if you are able to access the share from IE.. 

    4. If you are able to access from IE, then try doing filewebrequest from a console app.

    5. If this succeeds and still your asp.net fails, then there is a problem with impersonation.

     

    Wednesday, December 28, 2005 5:17 PM