Click here to Skip to main content
15,889,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

i need to transfer one file fom my system to a specified path in server.below is the code i did.but its throwing me error saying incorrect function.

C#
string username = "rsdfsf";
            string password = "sfsfsdf03";
            AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
            WindowsIdentity identity = new WindowsIdentity(username,password);   //Here its throwing the error....     
    WindowsIdentity.GetCurrent();
            WindowsImpersonationContext context = identity.Impersonate();

            try
            {
                File.Copy(@"C:\Documents and Settings\aj99823\Desktop\project\employeedetails1.txt", @"\\\\149.223.26.33\\D:\\Developers\muralim\TRW.HRM.Headcount_LMSFeed\Log\empps.txt", true);
            }
            catch
            {
                context.Undo();
            }  

can anyone plsssss help me.........???
Posted
Updated 23-May-12 23:21pm
v2
Comments
Sandeep Mewara 24-May-12 5:36am    
Winforms or ASP.NET?
Oshtri Deka 24-May-12 5:38am    
Give us entire error message.

1 solution

I'm not surprised it doesn't work - I would be amazed (and rather saddened) if it did.

Think for a moment about what you are trying to do:

"Read file file from your local pc, and write it to a specified folder, of a specified hard drive, of a computer somewhere else in the world, via the internet."

If you could do it that easily, what would stop me doing the same? And using your remote server for an internet backup, or file sharing device? And if it filled up a bit, deleting your files to make room for mine?

If you want to do that, then you need to look at setting up an FTP connection between your software and the server (assuming it is configured to accept FTP requests) and transfer the file that way. Google can help you there - it found this: C# FTP Client Library[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900