Note that there are some explanatory texts on larger screens.

plurals
  1. POFile.exists() working in localhost but not in IIS 7.5
    primarykey
    data
    text
    <p>I have a code in c#(asp.net) in which File.exists() returns a false value when I execute it in IIS 7.5 but returns a true value when I run it in my localhost via visual studio debugging.</p> <p>I've checked all the read and write permissions and all IIS users have all the permissions for the folder.</p> <p>Can anyone suggest any way to fix this?</p> <p>Attached is the code for reference:-</p> <pre><code>protected void downloadFiles(string nric) { string serverPath = Server.MapPath(@"~\Temp\"); string folderName = nric; string dirName = serverPath + folderName; string logFilePath = Server.MapPath(@"~\Temp\"); string logFile = logFilePath + "log2.txt"; FileStream fs = new FileStream(logFile, FileMode.Create, FileAccess.ReadWrite); StreamWriter logWriter = new StreamWriter(fs);//File.CreateText(logFile); logWriter.WriteLine("Preparing to export ....." + DateTime.Now.ToString()); try { logWriter.WriteLine("entered try loop"); Directory.CreateDirectory(dirName + "\\CollectionsItems"); DataTable dt = new DataTable(); dh.Fill("ACP", dt, "P_ACP_COLLECTION_VIEW_SEARCH_OWN", nric, "", "", ""); foreach (DataRow dRow in dt.Rows) { logWriter.WriteLine("entered for loop"); string fileURL = dRow["FILE_URL"].ToString(); logWriter.WriteLine("file URL =" + fileURL); string collectionFolder = dRow["COLLECTION_FOLDER"].ToString(); string collectionFile = Path.Combine(ConfigurationManager.AppSettings.Get("root") + "\\" + nric + "\\" + collectionFolder, fileURL); //string orgFile = collectionFile.Replace("\\", "/"); string orgFile = collectionFile; string filName = dirName + "\\CollectionsItems\\" + fileURL; logWriter.WriteLine("org file =" + orgFile); logWriter.WriteLine("file name =" + filName); //WebClient wc = new WebClient(); //wc.DownloadFile(new Uri(orgFile), filName); if (File.Exists(orgFile)) { logWriter.WriteLine("entered if loop"); FileStream readStream = new FileStream(orgFile, FileMode.Open, FileAccess.ReadWrite); FileStream writeStream = new FileStream(filName, FileMode.Create, FileAccess.Write); ReadWriteStream(readStream, writeStream); //File.Copy(orgFile,filName,true); } } logWriter.WriteLine(" "); logWriter.WriteLine("Exporting Completed ....." + DateTime.Now.ToString()); logWriter.Flush(); logWriter.Close(); } catch (Exception ex) { } } </code></pre> <p>Following are the log files generated in local host and IIS.</p> <p>localhost:- Preparing to export .....4/30/2013 5:03:46 PM entered try loop entered for loop file URL =CO201304262025117208.jpg org file =C:\inetpub\wwwroot\imprints3\Temp\demostu01\Achievements\CO201304262025117208.jpg file name =C:\inetpub\wwwroot\Cybersphere_imprints\Temp\demostu01\CollectionsItems\CO201304262025117208.jpg entered if loop entered for loop file URL =CO201304231616496601.jpg org file =C:\inetpub\wwwroot\imprints3\Temp\demostu01\Achievements\CO201304231616496601.jpg file name =C:\inetpub\wwwroot\Cybersphere_imprints\Temp\demostu01\CollectionsItems\CO201304231616496601.jpg entered if loop entered for loop file URL =CO201303281418567609.docx org file =C:\inetpub\wwwroot\imprints3\Temp\demostu01\Achievements\CO201303281418567609.docx file name =C:\inetpub\wwwroot\Cybersphere_imprints\Temp\demostu01\CollectionsItems\CO201303281418567609.docx</p> <p>Exporting Completed .....4/30/2013 5:03:46 PM</p> <p>IIS:- Preparing to export .....4/30/2013 5:05:57 PM entered try loop entered for loop file URL =CO201304262025117208.jpg org file =C:\inetpub\wwwroot\imprints3\Temp\demostu01\Achievements\CO201304262025117208.jpg file name =C:\inetpub\wwwroot\imprints3\Temp\demostu01\CollectionsItems\CO201304262025117208.jpg entered for loop file URL =CO201304231616496601.jpg org file =C:\inetpub\wwwroot\imprints3\Temp\demostu01\Achievements\CO201304231616496601.jpg file name =C:\inetpub\wwwroot\imprints3\Temp\demostu01\CollectionsItems\CO201304231616496601.jpg entered for loop file URL =CO201303281418567609.docx org file =C:\inetpub\wwwroot\imprints3\Temp\demostu01\Achievements\CO201303281418567609.docx file name =C:\inetpub\wwwroot\imprints3\Temp\demostu01\CollectionsItems\CO201303281418567609.docx</p> <p>Exporting Completed .....4/30/2013 5:05:57 PM</p> <p>As it can be seen, the difference in log files is that they are not entering the if loop which is weird as the files exist and the same function is entering the if loop in my localhost.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload