Closed chrisgate closed 2 years ago
maybe this file path format is different in Linux and windows
true @neozhu Again linux docker doesn't respect "Files\Images\ProfilePictures" to create folder tree like: --File --Images --ProfilePictures it will just create create one folder name with "Files\Images\ProfilePictures", i think that is the issue there.
Cheers
May have to rethink the hard coded path and use System.IO.Path.DirectorySeparatorChar
thanks @mikecasas can u give possible way of using System.IO.Path.DirectorySeparatorChar?
Thanks
@chrisgate Basically something like the below. I haven't dug into this repo too much, but I have come across this issue working with other projects.
SomePath = "Images" + DirectorySeparatorChar + "ProfilePictures"
@mikecasas you mentioning this (System.IO.Path.DirectorySeparatorChar) really helped me in digging deep. anyways,this extension does the job:
`private const char WinSeparator = '\'; private const char UnixSeparator = '/'; public static string NormalizePath(this string path) { if (string.IsNullOrEmpty(path)) return path;
if (Path.DirectorySeparatorChar == WinSeparator)
path = path.Replace(UnixSeparator, WinSeparator);
if (Path.DirectorySeparatorChar == UnixSeparator)
path = path.Replace(WinSeparator, UnixSeparator);
return path.Replace(string.Concat(WinSeparator, WinSeparator), WinSeparator.ToString());
}`
Thanks and Cheers!
Glad I can help. I'm not sure if you even need that logic. I think the framework knows what it is running on and "converts" the character.
https://docs.microsoft.com/en-us/dotnet/api/system.io.path.directoryseparatorchar?view=net-5.0
I think that logic is needed as seem below: https://github.com/blazorhero/CleanArchitecture/blob/637517163f1e7f40b6be0952f8cf4ab690d759e0/src/Infrastructure/Services/UploadService.cs#L18 All these Path.Combine changes the behavior based on platform u are running it.
in development everything is ok but in docker the folder are create like : Files --Images\ProfilePictures --1412cb20-cd01-41f3-bf26-4909db61614a-182989ef-9030-44ac-95dd-9d14249a8cde.jpg where on development using windows it will be: Files --Images --ProfilePictures -- 1412cb20-cd01-41f3-bf26-4909db61614a-182989ef-9030-44ac-95dd-9d14249a8cde.jpg Is this bug or i have done some wrong?