[英]How to read file from share folder by C#?
我想使用FileStream(C#)讀取另一台PC的共享文件夾中的文件(Windows)
FileStream file = new FileStream(filePath, FileMode.Open);
但是'System.IO.FileNotFoundException'
filePath = "\\sharefolder\test.csv"
filePath = @"\\sharefolder\test.csv"
filePath = "\\\\sharefolder\\test.csv"
(這三種方式都是FileNotFoundException)
我可以通過Windows資源管理器訪問此文件
通常,您將那些項目設置為要復制到bin文件夾中。 右鍵單擊solution explorer/navigator
,選擇properties
然后將“ Copy to output directory
設置為其他內容。
DirectoryInfo diSrc = new DirectoryInfo(@"\\Ip_Address_OfComputer\D(D or c Directory)\Shared folder");
DirectoryInfo diDest = new DirectoryInfo(@"D:\New folder at your machine");
CopyDirectory(diSrc, diDest, "174");
然后,您可以讀取文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.