Rename File/Folder name variables to distinguish them from real (full) paths
Make sure full path is used everywhere (if I didn't miss anything)
This commit is contained in:
1 parent
7b95942653
commit
03b9ea8e49
27 files changed
+165
-188
No files matched your search
@@ -273,6 +273,30 @@ namespace VocaluxeLib
|
||||
{
|
||||
return (bounds.X <= x) && (bounds.X + bounds.W >= x) && (bounds.Y <= y) && (bounds.Y + bounds.H >= y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a filename that is unique in that path
|
||||
/// </summary>
|
||||
/// <param name="path">Path in which the file should be stored</param>
|
||||
/// <param name="filename">filename (including extension)</param>
|
||||
/// <returns></returns>
|
||||
public static string GetUniqueFileName(string path, string filename, bool withPath = true)
|
||||
{
|
||||
string ext = Path.GetExtension(filename);
|
||||
filename = Path.GetFileNameWithoutExtension(filename);
|
||||
if (filename == null)
|
||||
filename = "1";
|
||||
if (File.Exists(Path.Combine(path, filename + ext)))
|
||||
{
|
||||
int i = 1;
|
||||
while (File.Exists(Path.Combine(path, filename + "_" + i + ext)))
|
||||
i++;
|
||||
filename += "_" + i;
|
||||
}
|
||||
if (withPath)
|
||||
filename = Path.Combine(path, filename);
|
||||
return filename + ext;
|
||||
}
|
||||
}
|
||||
|
||||
static class CEncoding
|
||||
|
||||
Reference in new issue
Block a user