0

I am currently working on a basic chatroom system for my college using text files, allowing everyone to save chatrooms in their area and share them with others. For this to work I need to get the actual directory of each users file on the server and not their local (relative) directory.

My college has a layout of each users E:\ drive being equal to \ServerName\Student\ (StudentNameHere)\ and in the past I have just been using .Replace("E:\","\\ServerName\Student\"+Enviroment.Username +"\")

But upon finding out that my college has different locations such as instead of Student lets say Student1, it makes my code more prone to breaking.

I have tried using

Path.GetFullPath(<File in this Users Directory>);

But it's only returned the path relative to users directory and not to the server, I don't know the type of link they used, but I thought symbolic would be good practice, tho trying this same command again on my own pc which I know has junction links for visual studio source/repos, didn't mention it's true (absolute) path either, any help on this would be much appreciated as this will fix a lot of bugs in my code and hopefully be a clean way to fix it all up as well, Thank You.

  • 1
    I'm not 100% sure to understand what you're trying to do, but that might be it: https://stackoverflow.com/questions/2067075/how-do-i-determine-a-mapped-drives-actual-path – Kevin Gosse Mar 25 '19 at 21:56
  • Even if you could get the underlying path to _their_ data, more than likely your app will be denied access –  Mar 25 '19 at 21:58
  • @MickyD I've got around the access permissions via giving my entire college access to a folder I own, so they can run the program and when they make a chat, the folder they select is then used with an icacls command to give full control to it to people in the chat. – Sebastian Southwell Mar 25 '19 at 22:02
  • @KevinGosse that does seem similar to the issue I am currently having and I will have a look, won't be able to confirm it's success unfortunately till tomorrow tho as I have to be on a college computer to test it, Thank You. – Sebastian Southwell Mar 25 '19 at 22:12
  • Well if that's the case _why_ do you need to know where _their data is_? They can just do a file-open-browser to their stuff then save to your folder. Am I missing something? Unless you are running some sneaky `secondary` process that is **not** running in the user's context. Having everyone doing a `icacls` is kinda extreme and old-school –  Mar 25 '19 at 22:13
  • @MickyD The main purpose of the program is to allow people to create their own chatrooms on their accounts, the program is intended to coordinate this, it tells people to make a room, and shares the folder containing a text file to all members of said room. Then acts as a chat room allow all members to read and write to the file, but no one else can access. The data location is so the members know where to read and write to the file. Who ever made that chatroom on their account is admin of it and can change settings for it as much as they please, even kicking people or making it public to all. – Sebastian Southwell Mar 25 '19 at 22:18
  • No problem. You might want to look into an alternative like `sockets` maybe? Wishing you well –  Mar 26 '19 at 01:48
  • @MickyD Thanks, did try looking into sockets actually, my computer science teacher did try teaching us how to use them but they don’t work on the server due to permissions, well for students anyway. – Sebastian Southwell Mar 26 '19 at 10:50

1 Answers1

0

Thanks To @KevinGosse (https://stackoverflow.com/users/869621/kevin-gosse)

The problem I was having was Server Based and the link you commented did help, Thank You I couldn't test this until today because I needed server access but it works like a charm, Thank You.

How do I determine a mapped drive's actual path?