Hi,
I'm trying to upload a file in my ASP.NET application (C#). In my
webform I have an input file control with runat=server. In my code written in the code behind file,I specify my destination directory as a network path and I'm using the function HttpPostedFile.SaveAs (string filename) to save the uploaded file. My code runs fine when my destination directory is on some machines, and produces an exception when my desrtination directory is on other machines although i made sure that all the directories I'm trying to upload my files on have read,change & full control permissions for EVERYONE.
The exception I'm getting is:
System.IO.IOException: Logon failure: unknown user name and/or bad password.
This is the function I'm using for Upoading files in the code behind file:
private void UploadFile(string sFileDir, long lMaxFileSize)
{
if (( Request.Files[0] != null) && (
Request.Files[0].ContentLength > 0))
{
//determine file name
string sFileName =
System.IO.Path.GetFileName(Request.Files[0].FileName);
try
{
if
(Request.Files[0].ContentLength <= lMaxFileSize)
{
//Save File on
disk
Request.Files[0].SaveAs(sFileDir + sFileName);
lblMessage.Visible=true;
lblMessage.Text="File: " + sFileDir + sFileName + " Uploaded
Successfully";
}
else //reject file
{
lblMessage.Visible=true;
lblMessage.Text="File Size if Over the Limit of " + lMaxFileSize ;
}
}
catch(Exception ex)//in case of
an error
{
lblMessage.Visible =
true;
lblMessage.Text="An
Error Occured. Please Try Again!";
lblMessage.Text+="ex.Message=" + ex.Message +
",ex.toString()="+ex.ToString();
}
}
}
Does anyone have a clue wha may be the cause of this exception
happening on some machines and not on others ? Do I have to set any other permissions except those set to EVERYONE on the destination directory ?
Thanks
I'm trying to upload a file in my ASP.NET application (C#). In my
webform I have an input file control with runat=server. In my code written in the code behind file,I specify my destination directory as a network path and I'm using the function HttpPostedFile.SaveAs (string filename) to save the uploaded file. My code runs fine when my destination directory is on some machines, and produces an exception when my desrtination directory is on other machines although i made sure that all the directories I'm trying to upload my files on have read,change & full control permissions for EVERYONE.
The exception I'm getting is:
System.IO.IOException: Logon failure: unknown user name and/or bad password.
This is the function I'm using for Upoading files in the code behind file:
private void UploadFile(string sFileDir, long lMaxFileSize)
{
if (( Request.Files[0] != null) && (
Request.Files[0].ContentLength > 0))
{
//determine file name
string sFileName =
System.IO.Path.GetFileName(Request.Files[0].FileName);
try
{
if
(Request.Files[0].ContentLength <= lMaxFileSize)
{
//Save File on
disk
Request.Files[0].SaveAs(sFileDir + sFileName);
lblMessage.Visible=true;
lblMessage.Text="File: " + sFileDir + sFileName + " Uploaded
Successfully";
}
else //reject file
{
lblMessage.Visible=true;
lblMessage.Text="File Size if Over the Limit of " + lMaxFileSize ;
}
}
catch(Exception ex)//in case of
an error
{
lblMessage.Visible =
true;
lblMessage.Text="An
Error Occured. Please Try Again!";
lblMessage.Text+="ex.Message=" + ex.Message +
",ex.toString()="+ex.ToString();
}
}
}
Does anyone have a clue wha may be the cause of this exception
happening on some machines and not on others ? Do I have to set any other permissions except those set to EVERYONE on the destination directory ?
Thanks