BoggyBayouBoy
asked on
Posting a file and evaluating its extension
I have a asp.net page that calls this code. If I post a file from the machine running IIS, this code works fine. If my posted file is from a network server, the code returns the null. See below
public DataSet GetOrderInfo(string logFileName) //bring the datafile into a dataset.
{
if (File.Exists(logFileName)) // if the file exists, create the dataset
{
if (logFileName.EndsWith("est "))
{
DataSet ds = CreateDEBOM(logFileName);
return ds;
}
else if (logFileName.Contains("xls "))
{
DataSet ds = CreateXLSBOM(logFileName);
return ds;
}
else
{
DataSet ds = CreateXLSBOM(logFileName);
return ds;
}
}
else
{
return null;
}
}
Please help me with this will ya?
public DataSet GetOrderInfo(string logFileName) //bring the datafile into a dataset.
{
if (File.Exists(logFileName))
{
if (logFileName.EndsWith("est
{
DataSet ds = CreateDEBOM(logFileName);
return ds;
}
else if (logFileName.Contains("xls
{
DataSet ds = CreateXLSBOM(logFileName);
return ds;
}
else
{
DataSet ds = CreateXLSBOM(logFileName);
return ds;
}
}
else
{
return null;
}
}
Please help me with this will ya?
What is the full logFileName that you are passing in each case?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
here's the value of the filename string. under the first scenario, it was uploaded from the local machine.
in the second, it was uploaded from a server.
FileUpload1.PostedFile.Fil eName (local machine)
"C:\\Documents and Settings\\Administrator\\D esktop\\sm all1.est"
FileUpload1.PostedFile.Fil eName (server)
"\\\\engineering\\DETruss\ \CRESTVIEW ELEMENTARY\\small1.est"
in the second, it was uploaded from a server.
FileUpload1.PostedFile.Fil
"C:\\Documents and Settings\\Administrator\\D
FileUpload1.PostedFile.Fil
"\\\\engineering\\DETruss\
ASKER
The file did not exist on the IIS server... that was the issue. Thanks!
Not a problem, glad I was able to help. ;=)