path-combine

Resolving relative paths with wildcards in C#

不羁的心 提交于 2020-05-12 11:45:21
问题 In C#, if I have a directory path and a relative file path with wildcard, e.g. "c:\foo\bar" and "..\blah\*.cpp" Is there a simple way to get the list of absolute file paths? e.g. { "c:\foo\blah\a.cpp", "c:\foo\blah\b.cpp" } Background There is a source code tree, where any directory can contain a build definition file. This file uses relative paths with wildcards to specify a list of source files. The task is to generate a list of absolute paths of all source files for each one of these build

System.ArgumentException illegal characters in path

≡放荡痞女 提交于 2020-01-03 16:45:23
问题 I am using Path.Combine, and one of the strings contain a Unicode characters. I get {System.ArgumentException} exception; illegal characters in path. According to MSDN filepath/name can have unicode characters. Why do I get this exception? Edit: Here is the code: Path.Combine("C:\PDM\Silver","Amabel Bender QQQ") 回答1: I figured out the problem. The second string contains a "tab" character in it causing the exception. (that didn't showed up when I pasted the string here) Thanks everyone and

System.ArgumentException illegal characters in path

好久不见. 提交于 2020-01-03 16:44:13
问题 I am using Path.Combine, and one of the strings contain a Unicode characters. I get {System.ArgumentException} exception; illegal characters in path. According to MSDN filepath/name can have unicode characters. Why do I get this exception? Edit: Here is the code: Path.Combine("C:\PDM\Silver","Amabel Bender QQQ") 回答1: I figured out the problem. The second string contains a "tab" character in it causing the exception. (that didn't showed up when I pasted the string here) Thanks everyone and

Is there a .NET API to return the equivalent extended-path string of a given path?

微笑、不失礼 提交于 2019-12-14 03:46:35
问题 In NTFS, I can prefix a path with the \\?\ character sequence to denote that it is a path that exceeds the 260-character limit; as such, the file system will interpret the path correctly and avoid raising PathTooLongException . (see http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#maxpath for more information) Is there a .NET API that will prefix my path strings with this sequence, or am I stuck writing my own? In essence, I am looking for a method that is equivalent to the

Why Path.Combine doesn't add the Path.DirectorySeparatorChar after the drive designator?

孤人 提交于 2019-12-06 17:00:54
问题 var actual = Path.Combine("c:", "filename"); var expected = @"c:\filename"; Assert.AreEqual(expected, actual); Result {Assert.AreEqual failed. Expected:<c:\filename>. Actual:<c:filename>. Why? 回答1: C:filename is a valid path and is different from C:\filename . C:filename is the file filename in the current directory on the C: drive whereas C:\filename is the file filename in the root of that drive. Apparently they wanted to keep the functionality of refering to the current directory on some

Why Path.Combine doesn't add the Path.DirectorySeparatorChar after the drive designator?

独自空忆成欢 提交于 2019-12-04 22:30:59
var actual = Path.Combine("c:", "filename"); var expected = @"c:\filename"; Assert.AreEqual(expected, actual); Result {Assert.AreEqual failed. Expected:<c:\filename>. Actual:<c:filename>. Why? C:filename is a valid path and is different from C:\filename . C:filename is the file filename in the current directory on the C: drive whereas C:\filename is the file filename in the root of that drive. Apparently they wanted to keep the functionality of refering to the current directory on some drive. This behaviour is described here in MSDN MSDN doesn't seem to explain why, but does provide