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:
59 Replies
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 executablethat still wont give ya access from other PCs would it?
But even when using that one somehow the file cant be located on other pc's
You mean, like, me being able to access your files? Well no, it's got nothing to do with remote access
nono
Well, I assume the file exists on your PC
Does it exist on theirs?
like when you pull the program from github
Do you, in any way, ensure that it does?
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)
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
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, somehowso they need to have it excatly the same place as mine?
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
?
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?ah thats what this is about, either use relative paths or absolute destinations utilizing the
SpecialFolders
is the way to go thenlike the persons.csv file
What is the file for? Is your application supposed to be stored in a specific folder?
its the same place on everyones pc
Well, yes
Because it's included in the repo, I assume
i can send a pic of what the app looks like
when running
And probably set as "copy always" or "copy if newer" in the properties
So it will always exist besides the
.exe
Not interested in the app, but the paths and the purpose of the file
And everybody who gets the source code, gets the file as well
copy always is on
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
the thing is that I can change values here thats the file being opened, but the others from my group cant change a thing
Why can't they change anything?
What exactly happens?
And how are they changing things?
Like they can't get the changes you made on your PC?
when i change a value and save its saves it but when they change a value and try to save it doens't
It just doesn't do anything?
nor these nor their own changes
excatly
They open the file in Excel and the changes are not there?
its like it only works for me
yup
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?
Are your friends downloading and building the whole repo, or do you just give them the bin?
the whole repo
Have them check
/bin
And just to make sure, do you push the bin to git? You are not supposed to
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
I dont think so but i do have a gitignore file if that changes anything
Good, it does. If it is configured correctly.
So, do check your bin for the copied excel
The persons.csv file is also under /bin
And when you make changes which of the two persons.csv is changed?
okay one sec
+ when your friends make changes, what file is affected
Its both
both of the files are being changed
do i need to delete one of them or something else?
ChatGpt says this:
So both are being changed on your side
What about the other people?
nothing on their side
Are both files changed for them as well?
So neither file?
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
the code works fine if it is used like this:
but this way it only works for me
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
In this pic i sent I use 3 different methods but none of them worked. Are one of these what you mean?