This is a migrated thread and some comments may be shown as answers.

Custom FileSystemProvider access denied when uploading.

1 Answer 55 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 13 Aug 2013, 04:24 PM
I am working on a FileSystemProvider that will allow writing to a physical or shared drive.  Most of the functionality seems to be working but the StoreFile method is having issues.

Below is the code I am using

public override string StoreFile(Telerik.Web.UI.UploadedFile file, string path, string name, params string[] arguments)
{
    var virtualSavePath = Path.Combine(path, name);
    var physicalPath = GetPhysicalFromVirtualPath(path);
    File.Create(Path.Combine(physicalPath, "joshtest"));
    if (physicalPath == null)
        return string.Empty;
 
    file.SaveAs(physicalPath);
 
    // Returns the path to the newly created file
    return virtualSavePath;
}

the file.SaveAs(physicalPath) throws an access denied exception.  The File.Create(...) works and creates the file so it seems that iis has access to create files. 

I am also able to create/delete/move folders and delete files (only tried to delete and upload files).

Am I missing something here that is causing file.SaveAs to not work properly?

1 Answer, 1 is accepted

Sort by
0
Josh
Top achievements
Rank 1
answered on 13 Aug 2013, 04:55 PM
I must have misunderstood what to pass SaveAs and was passing it the directory to save instead of the path+name.  Fixed and it appears to be working now.
Tags
FileExplorer
Asked by
Josh
Top achievements
Rank 1
Answers by
Josh
Top achievements
Rank 1
Share this question
or