Link to home
Start Free TrialLog in
Avatar of BoggyBayouBoy
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?
Avatar of jimstar
jimstar

What is the full logFileName that you are passing in each case?
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BoggyBayouBoy

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.FileName       (local machine)

"C:\\Documents and Settings\\Administrator\\Desktop\\small1.est"      

FileUpload1.PostedFile.FileName      (server)

"\\\\engineering\\DETruss\\CRESTVIEW ELEMENTARY\\small1.est"      
The file did not exist on the IIS server... that was the issue.  Thanks!
Not a problem, glad I was able to help. ;=)