开发者

Get File by path

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜