C
C#2y ago
<uzis>

❔ Pathing error issue in forms app, only on Linux

Hey! So i have this issue currently which i've been somewhat mindboggled over , basically all this function does is grab folders from that defined directory and spit their names right into a combobox, it works completely fine on windows. i usually like to have my app working on both linux and windows and ive ran into this error on Linux with my app that says "/n/n Invalid path", i had a thought that it might be due to this path thats defined here ORIGINALLY using backslashes because i've heard in the past that linux does not fare well with backslashes in paths. i use / now and it still errors, i tried defining the Working Directory next to the written path as thats what i thought might be needed incase linux/proton is just being picky. still errors, any ideas on what could be causing it would be gladly appreciated, thank you!
24 Replies
<uzis>
<uzis>OP2y ago
I know its due to this function because commenting it out when its loaded makes my app work completely fine
ero
ero2y ago
You're trying to get a Windows forms app to work on Linux...?
Mayor McCheese
Wine maybe?
Ⰽⰰⱈⰻⰽⱄ
Are you using correct case in path (Linux is case sensitive)?
<uzis>
<uzis>OP2y ago
Wine/Proton, im just trying to make sure it works on that aswell as windows, painfully
<uzis>
<uzis>OP2y ago
it should be the correct case, which is also confusing me
<uzis>
<uzis>OP2y ago
its the same on linux aswell, for the folders
Ⰽⰰⱈⰻⰽⱄ
I have some idea what could it be print WADPathExtension and DATPathExtension values Because it could have missing path separator In Linux directory paths does not have separator (/) at end It will work under mono natively, but Avalonia/ETO.Forms is better solution
ero
ero2y ago
i'm thinking it might not work because the implementation of System.IO may be windows-centric on this version? oh wait you can make winforms apps on .net 7 right
<uzis>
<uzis>OP2y ago
<uzis>
<uzis>OP2y ago
wait a minute philobofe im confused
Ⰽⰰⱈⰻⰽⱄ
I checked and in mono, aswell as in .net core it returns the same values
<uzis>
<uzis>OP2y ago
im gonna try something real quick its printing without "/" between path and "tracks" for some reason
Ⰽⰰⱈⰻⰽⱄ
But with mono it's some sort of true, for example it's funny how mono emulates registry on Unix systems In Linux directory paths does not have separator (/) at end
ero
ero2y ago
also where is that data directory located? can't be in root right if it's relative to the working directory, then you want to use ./data/...
<uzis>
<uzis>OP2y ago
but what about paths like this? should this error in linux?
<uzis>
<uzis>OP2y ago
somewhat updated code
<uzis>
<uzis>OP2y ago
data directory is located in the same folder as the application
ero
ero2y ago
ok we have some big issues here what does that foreach loop do exactly? @uzis?
Mayor McCheese
I was thinking similar
<uzis>
<uzis>OP2y ago
grabs these paths
ero
ero2y ago
string musicPacksPath = Path.Join(".", "data", "mod", "UserMods", "MusicPacks");
if (Directory.Exists(musicPacksPath))
{
foreach (string dir in Directory.GetDirectories(musicPacksPath))
{
string wad = Path.Join(dir, "tracks.wad");
string dat = Path.Join(dir, "tracks.dat");

Debug.WriteLine(wad);
Debug.WriteLine(dat);

comboBox1.Items.Add(Path.GetDirectoryName(dir));
}
}
string musicPacksPath = Path.Join(".", "data", "mod", "UserMods", "MusicPacks");
if (Directory.Exists(musicPacksPath))
{
foreach (string dir in Directory.GetDirectories(musicPacksPath))
{
string wad = Path.Join(dir, "tracks.wad");
string dat = Path.Join(dir, "tracks.dat");

Debug.WriteLine(wad);
Debug.WriteLine(dat);

comboBox1.Items.Add(Path.GetDirectoryName(dir));
}
}
you always want to use Path.Join (Path.Combine on older .net versions) if you're working with multiple operating systems you could (maybe should) be Debug.WriteLineing Path.GetFullPath(wad) instead
<uzis>
<uzis>OP2y ago
Solved it, this helped alot thank you!
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server