我想使用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"
(这3种方式都是FileNotFoundException)
我可以通过Windows资源管理器访问此文件
答案 0 :(得分:0)
通常,您将这些项目设置为要复制到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");
然后你可以阅读该文件。