Note that there are some explanatory texts on larger screens.

plurals
  1. POWont download file to My documents folder
    primarykey
    data
    text
    <p>One of my customers having a problem with my ActiveX control. The ActiveX is supposed to download an Excel file, save it in a folder in My documents and then Run Excel and open the file.</p> <p>Here is the code snippet for downloading and opening the file:</p> <pre><code> private string Checkout(string strFileUrl, string strPhysicalDir, string strPhysicalName) { string strMyDocumentFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string strCiroDocFolder = String.Format(@"{0}\CiroDoc", strMyDocumentFolder); string strCheckoutFolder = String.Format(@"{0}\{1}", strCiroDocFolder, strPhysicalDir); string strFilePath = String.Format(@"{0}\{1}", strCheckoutFolder, strPhysicalName); try { if (!Directory.Exists(strCiroDocFolder)) Directory.CreateDirectory(strCiroDocFolder); if (!Directory.Exists(strCheckoutFolder)) Directory.CreateDirectory(strCheckoutFolder); if (File.Exists(strFilePath)) File.Delete(strFilePath); WebClient myWebClient = new WebClient(); myWebClient.DownloadFile(strFileUrl, strFilePath); } catch (Exception e) { return e.Message; } return Run(strFilePath); } private string Run(string strFilePath) { if (!File.Exists(strFilePath)) return "filenotfound"; if (IsExecutable(strFilePath)) return "isexecutable"; try { System.Diagnostics.Process.Start(strFilePath); } catch (Exception e) { //This get returned return String.Format("{0} ({1})", e.Message, strFilePath); } return "success"; } </code></pre> <p>The Run method returns the exception "an error occurred when the command is sent to the program".</p> <p>When I check the My documents folder, the file is not there. Since it's not there, I would expect the Run method stop and return "filenotfound".</p> <p>This confuses me. Why does the <code>File.Exists</code> return <code>true</code>? Is it Windows file virtualization that kicks in and the file is saved in VirtualStore folder? If so, how can stop that behaviour? Or could it be something else in my customer's machine that causes this behaviour?</p> <p>I haven't been able to reproduce this problem on my own machine yet. If you know how I would be grateful.</p> <p>My customer's computer setup</p> <ul> <li>OS: Windows 7 </li> <li>Browser: IE 10</li> <li>Antivirus: McAfee</li> </ul> <p>If there is some relevant information Im missing I'll try to get it.</p>
    singulars
    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.
 

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