How can I make a Server which have SharedFile function? - c#

I am going to do a project with two requires such as:
Establish a service at Server which have shareFile function and folder.
Use WCF model, In Client-side, we will use TreeView to show all files or folders that shared by Server, and when we click a folder or file, it was opened direct on the Server (not Download it to open ). ===> look like we share file and folder between many computers.
I know how to use TreeView to show all files or folders in Client-Side, but I don't know How can I make a Server which have ShareFile function on the Internet.

It looks like you're trying to write an SMB server in C#.
You will need to understand the SMB protocol and implement in in C# using raw sockets.
WCF will not help you.

Related

Read files from client folder and upload to server - ASP.NET

What is the best way to get files from client folder (a folder that the client will choose the path) and upload to server?
Thanks.
You can't.
For privacy reasons, code from web sites running in a browser context is not allowed to enumerate files or directories on the client machine and send that information to a server. Imagine what would happen if it could!
You could possibly get around this limitation with some more complicated solution that includes a client side install (e.g. an ActiveX control) but this is simply not possible with ASP.NET alone.

Sending file in lan without a client/server solution

I working on a windows forms project, visual studio 2010, c#
I want to send some files to computers in our network but they don't have a "listener" as in client/server solution but i do have username/password. Is there any way to send files knowing this information? And as i said, i do not want to build a client / server solution.
Cant i use "Impersonate" somehow?
If you know the username password and your client is within the same domain, you might be able to use UNC with authentication (with $) and send the files to client PC. Something like: \\clientPC\c$. Once authenticated, you can just use File IO, e.g. File.Copy(..."\\clientPC\c$\yourfile.txt") to send file.
You can use the class posted here for UNC authentication.
Is this in the same domain as your machine? If so, do you have the ability to create a share? If you can, you may be able to just setup a share and transfer the files as you would locally. If this is possible there is no point in creating a verbose application for a trivial need.
I built similar for a company I used to work for, the "client" exposed a share and me; the "server" simply used File.Move() to transfer files.
Yes you can use impersonate,
Read this article
, Maybe it will helpful.

Simulate a network share in order to share files

Often times a program requires a file that happens to be on a network location. Take for instance Outlook. If I where to place an outlooks database (.pst file) in a network location then windows will make that "transparent" to the user and outlook will still be able to work. Another example could be quickbooks and many more. (as long as you have permissions to write and read)
For this example let's use Microsoft Word. If I would want to open a file in some other computer in the network I would be able to navigate to it as:
and open the file that I want because we are on the same network.
Now my question is how will I be able to simulate that? I want to have a virtual directory on the internet where I can place lets say my .pst file and then select it from windows explorer as:
(this example obviously does not work)
Will it be possible to do that? I believe windows uses a tcp connection with the host computer and then the host responds with he files that it shares. I will like to implement a program that does that so that I could avoid having to create a vpn. Also it will be nice if I could have my pst (outlook database file) on the internet so that all my computers open the same outlook database.
Note my purpose of this question is to open an outlook database file on a network location. I will like to be able to select a file on the internet from windows open file dialog. Also in todays world everything pretty much exists. I will like to create it lol
Windows provides a network redirector for CIFS (Common Internet File System, formerly SMB Server Message Block) resources. Writing a CIFS server is the easiest approach.
But you can also use one of the other existing redirectors, such as NFS, WebDAV, or Netware. And it's also possible to write new redirectors (though that requires kernel mode code, there are some development kits that provide the kernel code for you, similar to a Linux FUSE filesystem).
If you want to avoid writing code, WebDAV over HTTPS will provide you secure access (no need for a VPN layer) and software already exists.
It depends on how the server on the internet is set up to make its files available. Most often tcpip is not the protocol used for this - it is FTP, SFTP, HTTP or something similar. I believe Windows Explorer uses RPC calls over a local network to accomplish this. I don't think you will be able to use the Open File Dialog, you will have to write something similar that works over the protocol you need to use.

Acessing files from a Server remotely

As the title says, I need to access files from a server remotely. After doing this, I need to show the files in a windows file/folder Dialog style.
I need this using Remoting.
It's not that simple since I have some problems:
I don't have access to the client UNC sharing;
I don't know where the \server\xpto is physically pointed;
The service at the server must use the physical path.
Also, the sharing must be enabled (not always is), I'd need to prompt username/password and I'd have the network path, not the physical.
So, it's like accessing a server in a data center using the client app.
I guess you can do it by a web application. Create a page on the server which can reach the local files on the server and displays a list of them on a grid. You can add some commands on the files as well. The page you created would act as a middleware to reflect the operations you want on the files.
hope it helps.

How can I temporary map a FTP server to a network folder?

I'm creating an application to synchronize a local folder on my computer with a FTP server.
Since I don't wan't to access the FTP server directly over it's address, because it would be really complicated, I wan't to map the server temporary to a network folder so that my synchronization algorithm can work on it like on a local folder.
Is there something like this:
//Map the server to the specified path
FtpMapper.MapFtpServer("ftp://myserver/", "username", "password", "M:\\");
DirectoryInfo info = new DirectoryInfo("M:\\");
/* Do some work on the directory */
FtpMapper.UnmapFtpServer();
There isn't such a library, as far as I know.
This requires a windows filesystem driver that understands FTP commands and a .NET wrapper over it.
I have seen such drivers (without a wrapper) as part of commercial FTP suites, but nothing open source or free.
NetDrive boasts offering an SDK that lets you use it (netdrive) from your application. This is your only option if you don't want to write FTP code (or use third-party FTP component).
A programming solution to your task would be to take our Callback File System (to create a virtual drive) and our FTPSBlackbox (FTP/FTPS components for .NET) and combine them in your application.

Categories