开发者

Get File by path

开发者 https://www.devze.com 2023-03-18 09:05 出处:网络
I found I could get a file by: var files = System.IO.Directory.GetFiles(\"Some Directory\"); The file is one contained within this collection;

I found I could get a file by:

var files = System.IO.Directory.GetFiles("Some Directory");

The file is one contained within this collection;

Howev开发者_如何转开发er is there a method to get a single file by passing the file path tothis method?


There are alot of ways to directly access a file by path. Here are a few:

        string path = // path string here

        File.ReadAllText(path);

        File.OpenRead(path);

        File.OpenWrite(path);

Essentially everything the 'File' class does is related to a single file. Its a static class in the System.IO namespace.

http://msdn.microsoft.com/en-us/library/system.io.file.aspx


http://msdn.microsoft.com/en-us/library/b9skfh7s.aspx

System.IO.File.Open

0

精彩评论

暂无评论...
验证码 换一张
取 消