将文件从一个路径复制到另一路径

编程入门 行业动态 更新时间:2024-10-07 21:44:45
本文介绍了将文件从一个路径复制到另一路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我需要将系统中的一个文件传输到server中的指定路径.下面是我做的代码.但是它抛出错误,提示不正确的功能.

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.

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.........???

推荐答案

我并不惊讶它不起作用-我会如果确实如此,那一定会感到惊讶(甚至感到难过). 想一想您要做什么: 通过互联网从本地PC读取文件文件,并将其写入世界上其他地方的计算机的指定文件夹,指定硬盘驱动器中." 如果您可以轻松地做到这一点,那么什么会阻止我这样做呢?并使用远程服务器进行Internet备份或文件共享设备?如果它填满了一点,请删除您的文件以为我留出空间? 如果要这样做,则需要查看在软件和服务器之间建立FTP连接(假设已将其配置为接受FTP请求)并以这种方式传输文件. Google可以在这里为您提供帮助-它找到了以下内容: C#FTP客户端库 [ ^ ] 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[^]

更多推荐

将文件从一个路径复制到另一路径

本文发布于:2023-11-30 18:28:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651068.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!