C # - I / O on the network [closed]

0

I have a program that does I / O of files (create, edit, save), but I need to put it to do this I / O with files that are in the company network, both reading and writing.

My question is: Does my program need file read and write permission, or does the program user need these permissions on his machine to the network?

If the user needs to have this permission, can I put the address of the network server in Path that I use to save the program files? Or is something more necessary?

If it is permission of my program, written in C #, what exactly is needed?

    
asked by anonymous 02.05.2016 / 21:13

2 answers

3
  

Does my program need file read and write permission, or does the program user need these permissions on his machine to the network?

Who needs to have the read / write permission is the user, not the application.

  

If the user needs to have this permission, can I put the address of the network server in the Path I use to save the program files? or is something more necessary?

Yes, you should use the network path as if it were a local path. It's all the same.

Of course there may be some restrictions that invalidate what was said above, but since there are no more details, there is no way to be sure.

    
02.05.2016 / 21:28
2

Come on, your program about running under a user's authentication, always. With this in mind it is easy to understand that this user should rather have access to the file they want to open via the app.

However, not always the same user running your app is the same user who will access the file remotely. You can instead have a unique remote file access account.

In this case, you can use the impersonate technique. I found this file on en Working with Impersonate and Web . In the end you will do something like this:

using (ImpersonateConnection)
{
    // Este trecho de código irá rodar sob outro usuário
    var file = File.OpenRead(@"\Servidor\PastaCompartilhada\arquivo.txt");
    // ... outra coisas
}
    
02.05.2016 / 21:59