C# - Easiest way to parse filename with spaces eg. “C:\Test\File with spaces.txt”

前端 未结 6 2189
孤独总比滥情好
孤独总比滥情好 2021-01-04 23:30

I am trying to pass a full file path to FFMPEG.

C:\\TestFolder\\Input\\Friends - Season 6 - Gag Reel.avi

and it\'s obviously not liking th

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-04 23:43

    are you using FileInfo class?

    it contains (almost) everything about a file, including attributes and file versions, and you don't have to worry about spaces or other unwanted characters. As long as the file exists, it works well on FileInfo.

    use it as
    FileInfo f = new FileInfo(fullPathEvenWithSpaces);

提交回复
热议问题