开发者

ASPx Upload Control not saving file in correct location

I have my upload control saving a file to a mapped network drive on the web server. Even if I hard code a path, it still saves the file in the root directory of the mapped network drive.

Here is my code for the upload...

protected void ASPxUploadControl1_FileUploadComplete(object sender, DevExpress.Web.ASPxUploadControl.FileUploadCompleteEventArgs e)
    {
        if (e.IsValid)
        {  
            string uploadDirectory =开发者_Go百科 "//DOCSD9F1/TECHDOCS/";

            string fileName = e.UploadedFile.FileName;

            string path = "T:/Manuals/";

            e.UploadedFile.SaveAs(path + fileName);
            e.CallbackData = fileName;
        }
    }

On the web server, the mapped network drive is used as an index to host some documents, and the path on IIS is //DOCSD9F1/TECHDOCS/ ... but in windows explorer it is T:/ .. I have tried hard coding each of these into the path name but the file still saves to the root T:/ directory and not the sub directory I give it..

The folders are not read-only like I first assumed so I am stuck from here


Have you tried with backslashes instead of slashes:

string uploadDirectory = @"\\DOCSD9F1\TECHDOCS";
...
e.UploadedFile.SaveAs(Path.Combine(uploadDirectory, fileName));

For local paths, use backslashes. For URLs use slashes.

Also note, that your web application will typically run under a system account where mapped network drives like "T:\" are not available (these are available for the logged in user).


Use backslashes, like in "\\DOCSD9F1\TECHDOCS".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜