C
C#12mo ago
altintas12

Can't seem to make a universal filepath

Hi there could anyone explain how I can make a universal filepath so other pc's can locate the files, and make changes to them? Here I will post a picture of my attempts:
No description
59 Replies
Angius
Angius12mo ago
Your second comment seems right Environment.SpecialFolder is what you want to use Or just use relative paths to place the files next to the executable
cap5lut
cap5lut12mo ago
that still wont give ya access from other PCs would it?
altintas12
altintas12OP12mo ago
But even when using that one somehow the file cant be located on other pc's
Angius
Angius12mo ago
You mean, like, me being able to access your files? Well no, it's got nothing to do with remote access
altintas12
altintas12OP12mo ago
nono
Angius
Angius12mo ago
Well, I assume the file exists on your PC Does it exist on theirs?
altintas12
altintas12OP12mo ago
like when you pull the program from github
Angius
Angius12mo ago
Do you, in any way, ensure that it does?
cap5lut
cap5lut12mo ago
there are multiple ways of sharing, some of these are - host an FTP server on the machine - host an HTTP server/some web application on the machine - using SMB to share files/folder (this is the network sharing protocol which windows uses)
altintas12
altintas12OP12mo ago
when my group pulls the project they get the file, but then they cant change anything in the file because their filepath is different from mine
Angius
Angius12mo ago
You did not notice the "nono"? Well, you will need to ensure the file actually exists in this location For example, you might have a stuff.txt file on your desktop But other people might not So... you will need to ensure they do, somehow
altintas12
altintas12OP12mo ago
so they need to have it excatly the same place as mine?
Angius
Angius12mo ago
Either use relative paths and package all the necessary files together with your app Or create the file at runtime Or otherwise ensure the file exists
altintas12
altintas12OP12mo ago
?
Angius
Angius12mo ago
Well, yes If your program expects a stuff.txt file to be on the desktop, and it's not there, what is it to do?
cap5lut
cap5lut12mo ago
ah thats what this is about, either use relative paths or absolute destinations utilizing the SpecialFolders is the way to go then
altintas12
altintas12OP12mo ago
No description
altintas12
altintas12OP12mo ago
like the persons.csv file
Denis
Denis12mo ago
What is the file for? Is your application supposed to be stored in a specific folder?
altintas12
altintas12OP12mo ago
its the same place on everyones pc
Angius
Angius12mo ago
Well, yes Because it's included in the repo, I assume
altintas12
altintas12OP12mo ago
i can send a pic of what the app looks like when running
Angius
Angius12mo ago
And probably set as "copy always" or "copy if newer" in the properties So it will always exist besides the .exe
Denis
Denis12mo ago
Not interested in the app, but the paths and the purpose of the file
Angius
Angius12mo ago
And everybody who gets the source code, gets the file as well
altintas12
altintas12OP12mo ago
No description
altintas12
altintas12OP12mo ago
copy always is on
Angius
Angius12mo ago
Then that's done The file will be available to everybody who has the source code or the published app Provided you include it with the build
altintas12
altintas12OP12mo ago
the thing is that I can change values here thats the file being opened, but the others from my group cant change a thing
Angius
Angius12mo ago
Why can't they change anything? What exactly happens? And how are they changing things?
Denis
Denis12mo ago
Like they can't get the changes you made on your PC?
altintas12
altintas12OP12mo ago
when i change a value and save its saves it but when they change a value and try to save it doens't
Angius
Angius12mo ago
It just doesn't do anything?
altintas12
altintas12OP12mo ago
nor these nor their own changes excatly
Angius
Angius12mo ago
They open the file in Excel and the changes are not there?
altintas12
altintas12OP12mo ago
its like it only works for me yup
Angius
Angius12mo ago
Seems like it has nothing to do with the paths, then But rather with the file becoming read-only for them or something Are they running the app from source code, or from a published build?
Denis
Denis12mo ago
Are your friends downloading and building the whole repo, or do you just give them the bin?
altintas12
altintas12OP12mo ago
the whole repo
Angius
Angius12mo ago
Have them check /bin
Denis
Denis12mo ago
And just to make sure, do you push the bin to git? You are not supposed to
Angius
Angius12mo ago
That's where the build artifacts go Alongside the exe and the copied file So it's possible that the source file won't be changed, but the one next to the build will
altintas12
altintas12OP12mo ago
I dont think so but i do have a gitignore file if that changes anything
Denis
Denis12mo ago
Good, it does. If it is configured correctly. So, do check your bin for the copied excel
altintas12
altintas12OP12mo ago
The persons.csv file is also under /bin
altintas12
altintas12OP12mo ago
No description
Denis
Denis12mo ago
And when you make changes which of the two persons.csv is changed?
altintas12
altintas12OP12mo ago
okay one sec
Denis
Denis12mo ago
+ when your friends make changes, what file is affected
altintas12
altintas12OP12mo ago
Its both both of the files are being changed do i need to delete one of them or something else? ChatGpt says this:
altintas12
altintas12OP12mo ago
No description
Angius
Angius12mo ago
So both are being changed on your side What about the other people?
altintas12
altintas12OP12mo ago
nothing on their side
Angius
Angius12mo ago
Are both files changed for them as well? So neither file?
altintas12
altintas12OP12mo ago
nothing gets changed for them wheter I or they make a change yeah they cant make a change in the file it doesnt save their changes
altintas12
altintas12OP12mo ago
the code works fine if it is used like this:
No description
altintas12
altintas12OP12mo ago
but this way it only works for me
Denis
Denis12mo ago
Wait you use this path to get to the file? It is an absolute path which, moreover, includes your specific username. You should use a relative path
altintas12
altintas12OP12mo ago
In this pic i sent I use 3 different methods but none of them worked. Are one of these what you mean?
No description
Want results from more Discord servers?
Add your server