- How to convert between URI and normal file path:
- Convert normal file path to URI: Uri uri = new Uri(@"c:\Documents\myfile");
- Convert URI to normal file path: string normalPath = new Uri(uriPath).LocalPath;
- How to get file name or file extension from URI or normal file path:
- string fileName = Path.GetFileName(path); string fileExt = Path.GetExtension(path); // path can be both URI and normal file path.
- FileInfo fi = new FileInfo(path); string fileName = fi.Name; string fileExt = fi.Extension. // path can only be normal file path. Disadvantage: must need a FileInfo instance first.
- string fileName = Path.GetFileName(path); string fileExt = Path.GetExtension(path); // path can be both URI and normal file path.
Path File URI
最新推荐文章于 2024-10-24 10:21:29 发布