简体   繁体   中英

How to copy files from client system directory to server system directory via remoting

I am copying files from one path to another path in my pc as

        string destpath= Application.StartupPath + @"\Multiple Documents1";
        string soucepath= @"D:\Naresh WORK AREA\Naresh\Multiple Documents1";
        if (!File.Exists(path))
        {
         DirectoryInfo dir = Directory.CreateDirectory(path);
        }
        System.IO.File.Copy(soucepath, destpath+@"\"+filename.doc, true); 

It works fine in single user inveronment. Now I am using remoting with windows service, I want to save the file into server i'e where my service is running. If I take my source path to the server, it will not identify the sourcepath as the client system path. I know the destination path is service startuppath. But How can I take my source path to service running system.

Instead of using local absolute paths you can use UNC paths as in \\ComputerName\\ShareName. The account your Windows Service is running under of course Needs proper permissions to access the Shares. When configuring your service, use the perspective of the server the service is running on. So you need to use a UNC path for the client directory, but you can keep the absolute path on the server side. You can set up a new share on the client computer in Windows Explorer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM