我正在编写一个程序,它使用.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
----------------------------------------
任何想法我该怎么办?
问题是,我不得不存储在调试/释放箱而不是主程序文件夹中的.csv文件。 解决的链接:https://social.msdn.microsoft.com/Forums/en-US/b5e244c1-a409-4742-8180-46182ddb8324/attach-csv-files-to-deployed-program?forum=winformssetup 谢谢反正! – Alexzandelli