2017-08-01 34 views
-1

我正在編寫一個程序,它使用.csv文件中的數據填充listBoxes。已發佈的程序找​​不到CSV文件

它在調試/發佈時完美運行,但是當我嘗試發佈該程序時,無法找到.csv/DEPLOY文件。

在解決方案資源管理器中,.csv文件的「Build Action」屬性設置爲「Content」,「Copy to Output Directory」設置爲「Always always」,並設置爲「Include(Auto)」在「發佈標籤」中的「應用程序文件」文件夾中。

當我雙擊下載的「設置」應用程序,它成功地安裝該程序,然後說:「找不到文件」,並在下拉細節:

************** Exception Text ************** 

System.IO.FileNotFoundException: Could not find file 'C:\Users\aplattel\AppData\Local\Apps\2.0\G6C5PO3Q.NM9\EEX9H3AC.7ZE\jump..tion_9801a5e0f1d741c2_0001.0000_5fc10f3e2273aaad\ProductA.csv'. 
File name: 'C:\Users\aplattel\AppData\Local\Apps\2.0\G6C5PO3Q.NM9\EEX9H3AC.7ZE\jump..tion_9801a5e0f1d741c2_0001.0000_5fc10f3e2273aaad\ProductA.csv' 
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) 
    at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost) 
    at System.IO.StreamReader..ctor(String path) 
    at Jumper_Assemblies.JumperAssembly.JumperAssembly_Shown(Object sender, EventArgs e) 
    at System.Windows.Forms.Form.OnShown(EventArgs e) 
    at System.Windows.Forms.Form.CallShownEvent() 
    at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme) 
    at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj) 
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
    at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) 
    at System.Windows.Forms.Control.InvokeMarshaledCallbacks() 


************** Loaded Assemblies ************** 
mscorlib 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.7.2053.0 built by: NET47REL1 
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll 
---------------------------------------- 
Jumper_Assemblies 
    Assembly Version: 1.0.0.0 
    Win32 Version: 1.0.0.0 
    CodeBase: file:///C:/Users/aplattel/AppData/Local/Apps/2.0/G6C5PO3Q.NM9/EEX9H3AC.7ZE/jump..tion_9801a5e0f1d741c2_0001.0000_5fc10f3e2273aaad/Jumper_Assemblies.exe 
---------------------------------------- 
System.Windows.Forms 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.7.2053.0 built by: NET47REL1 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll 
---------------------------------------- 
System 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.7.2053.0 built by: NET47REL1 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll 
---------------------------------------- 
System.Drawing 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.7.2053.0 built by: NET47REL1 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll 
---------------------------------------- 
System.Configuration 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.7.2053.0 built by: NET47REL1 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll 
---------------------------------------- 
System.Core 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.7.2053.0 built by: NET47REL1 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll 
---------------------------------------- 
System.Xml 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.7.2053.0 built by: NET47REL1 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll 
---------------------------------------- 

任何想法我該怎麼辦?

回答

0

您可以使用after build操作將文件複製到您瞭解的位置或使用對文件的相對引用(。\ ProductA.csv)。

準確的位置將取決於您的文件結構。

+0

問題是,我不得不存儲在調試/釋放箱而不是主程序文件夾中的.csv文件。 解決的鏈接:https://social.msdn.microsoft.com/Forums/en-US/b5e244c1-a409-4742-8180-46182ddb8324/attach-csv-files-to-deployed-program?forum=winformssetup 謝謝反正! – Alexzandelli

相關問題