Revision e81dd1f6 trunk/Pithos.Interfaces/FileInfoExtensions.cs
b/trunk/Pithos.Interfaces/FileInfoExtensions.cs | ||
---|---|---|
74 | 74 |
var parentDirInfo = dirInfo.Parent; |
75 | 75 |
if (null == parentDirInfo) |
76 | 76 |
return dirInfo.Name; |
77 |
return Path.Combine(GetProperDirectoryCapitalization(parentDirInfo.FullName), |
|
78 |
parentDirInfo.GetDirectories(dirInfo.Name)[0].Name); |
|
77 |
|
|
78 |
try |
|
79 |
{ |
|
80 |
|
|
81 |
|
|
82 |
if (dirInfo.Exists) |
|
83 |
return Path.Combine(GetProperDirectoryCapitalization(parentDirInfo.FullName), |
|
84 |
parentDirInfo.GetDirectories(dirInfo.Name)[0].Name); |
|
85 |
else |
|
86 |
{ |
|
87 |
return dirInfo.FullName; |
|
88 |
} |
|
89 |
} |
|
90 |
catch (DirectoryNotFoundException) |
|
91 |
{ |
|
92 |
//An exception can occur if a directory is deleted right after the Exists call |
|
93 |
return dirInfo.FullName; |
|
94 |
} |
|
79 | 95 |
} |
80 | 96 |
|
81 | 97 |
|
... | ... | |
104 | 120 |
//Directory will not be null for an absolute path |
105 | 121 |
Contract.Assume(dirInfo != null); |
106 | 122 |
|
107 |
return Path.Combine(GetProperDirectoryCapitalization(dirInfo.FullName), |
|
108 |
dirInfo.GetFiles(fileInfo.Name)[0].Name); |
|
123 |
try |
|
124 |
{ |
|
125 |
|
|
126 |
if (fileInfo.Exists) |
|
127 |
return Path.Combine(GetProperDirectoryCapitalization(dirInfo.FullName), |
|
128 |
dirInfo.GetFiles(fileInfo.Name)[0].Name); |
|
129 |
else |
|
130 |
{ |
|
131 |
return fileInfo.FullName; |
|
132 |
} |
|
133 |
} |
|
134 |
catch (FileNotFoundException) |
|
135 |
{ |
|
136 |
//An exception can occur if a file is deleted right after the Exists call |
|
137 |
return fileInfo.FullName; |
|
138 |
|
|
139 |
} |
|
109 | 140 |
} |
110 | 141 |
|
111 | 142 |
public static string GetProperCapitalization(this FileSystemInfo info) |
Also available in: Unified diff