FileCopy到共享文件夹 [英] FileCopy to a shared folder

查看:82
本文介绍了FileCopy到共享文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试以下操作时:


System.IO.File.Copy(" C:\\test_read\\test.txt",
" \\\\192.168.0.5 \\test_write\\test.txt",false)


我收到UnauthorizedAccessException 。


但是,我似乎无法找到如何授权文件副本(即。

处理用户/通行证)。


我肯定必须有一种方法可以做到这一点,而无需编写一个

服务器应用程序,通过tcp / ip将传输的文件保存到本地

文件夹...


任何人?

When I try the following:

System.IO.File.Copy("C:\\test_read\\test.txt",
"\\\\192.168.0.5\\test_write\\test.txt", false)

I get an UnauthorizedAccessException.

I cannot however, seem to find out how to authorize the file copy (ie.
process the user/pass).

I''m sure there must be a way I can do this without resorting to writing a
server application that saves a transmitted file over tcp/ip to a local
folder...

Anyone?

推荐答案

尝试做一个净使用在那个UNC看看你是否可以访问它

首先..也检查写访问权限。这可能是您的NT用户的问题

权限。


-

John Wood

博客: http://dotnetjunkies.com/weblog/johnwood

" BLiTZWiNG" < BL ******* @ discussions.microsoft.com>在留言中写道

新闻:A5 ********************************** @ microsof t.com ...
Try doing a "net use" on that UNC to see whether you have access to it
first.. also check write access. This is probably an issue with your NT user
permissions.

--
John Wood
Blog: http://dotnetjunkies.com/weblog/johnwood
"BLiTZWiNG" <BL*******@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.com...
当我尝试以下操作时:

System.IO.File.Copy(" C:\\test_read\\ test .txt",
" \\\\192.168.0.5 \\test_write \\test.txt",false)

我收到了UnauthorizedAccessException。

然而,我似乎无法找到如何授权文件副本(即
处理用户/通行证)。

我肯定在那里必须是一种我可以做到这一点的方式,而无需编写一个
服务器应用程序,通过TCP / IP将传输的文件保存到本地
文件夹......

任何人?
When I try the following:

System.IO.File.Copy("C:\\test_read\\test.txt",
"\\\\192.168.0.5\\test_write\\test.txt", false)

I get an UnauthorizedAccessException.

I cannot however, seem to find out how to authorize the file copy (ie.
process the user/pass).

I''m sure there must be a way I can do this without resorting to writing a
server application that saves a transmitted file over tcp/ip to a local
folder...

Anyone?



对不起,我应该先详细说明。共享文件夹位于

Win2k3服务器上,该服务器配备了我是其管理员的SQL服务器。


我的客户端的部分解决方案是一个应用程序上传文件

到服务器以及成员信息和其他相关数据到SQL

服务器。没有求助于服务器应用程序,知道我的客户对b / b $ b不满意更先进的技术(即FTP),我想用了一个

安全共享文件夹,我的应用程序将文件复制到

是客户技能水平和

开发时间方面最简单的解决方案。


但是,C#/ .NET中的应用程序编程对我来说是新的,并且在使用System.IO和System.Security.Permissions之后,我仍然看不到

找到一种从服务器请求身份验证的方法。


" John Wood"写道:
Sorry I should have elaborated first. The shared folder is located on a
Win2k3 server equipped with SQL server of which I am the administrator of.

Part of my solution for my client is for an application to upload documents
to the server as well as member information and other related data to the SQL
server. Without resorting to a server application, knowing that my clients
are not confident with more advanced technology (ie FTP), I figured use of a
secure shared folder to which my application will copy the documents to would
be the simplest solution in terms of both the client skill level and
development time.

However, appliaction programming in C#/.NET is new to me, and after
perusings System.IO and System.Security.Permissions I still can''t seem to
find a way to request authentication from the server.

"John Wood" wrote:
尝试做一个净使用在那个UNC看看你是否可以访问它
首先..也检查写入权限。这可能是你的NT用户
权限的一个问题。

-
John Wood
博客: http://dotnetjunkies.com/weblog/johnwood

" BLiTZWiNG" < BL ******* @ discussions.microsoft.com>在消息中写道
新闻:A5 ********************************** @ microsof t.com。 ..
Try doing a "net use" on that UNC to see whether you have access to it
first.. also check write access. This is probably an issue with your NT user
permissions.

--
John Wood
Blog: http://dotnetjunkies.com/weblog/johnwood
"BLiTZWiNG" <BL*******@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.com...
当我尝试以下操作时:

System.IO.File.Copy(" C:\\test_read\\test.txt",
" \\\\\\ 192.168.0.5 \\test_write \\test.txt",false)

我收到了UnauthorizedAccessException。

然而,我似乎无法找到如何授权文件副本(即
处理用户/通行证)。

我肯定必须有办法我可以这样做,而无需编写一个
服务器应用程序,通过tcp / ip将传输的文件保存到本地
文件夹......

任何人?
When I try the following:

System.IO.File.Copy("C:\\test_read\\test.txt",
"\\\\192.168.0.5\\test_write\\test.txt", false)

I get an UnauthorizedAccessException.

I cannot however, seem to find out how to authorize the file copy (ie.
process the user/pass).

I''m sure there must be a way I can do this without resorting to writing a
server application that saves a transmitted file over tcp/ip to a local
folder...

Anyone?




如果您需要使用除当前登录到工作站的人员以外的凭据,那么你需要看一下

WindowsIdentity.Impersonate方法
http://msdn.microsoft.com/library/en...classtopic.asp


HTH


-

--- Nick Malik [微软]

MCSD, CFPS,认证Scrummaster
http://blogs.msdn.com/nickmalik


免责声明:在这个论坛上发表的意见是我自己的,而不是我雇主的b $ b代表。

我不知道代表我的雇主回答问题。我只是一个帮助程序员的
程序员。

-

" BLiTZWiNG" < BL ******* @ discussions.microsoft.com>在消息中写道

新闻:E5 ********************************** @ microsof t.com ...
if you need to use credentials other than that of the person currently
logged in to the workstation, then you need to look at the
WindowsIdentity.Impersonate method
http://msdn.microsoft.com/library/en...classtopic.asp

HTH

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I''m just a
programmer helping programmers.
--
"BLiTZWiNG" <BL*******@discussions.microsoft.com> wrote in message
news:E5**********************************@microsof t.com...
对不起我应该先详细说明。共享文件夹位于配备SQL服务器的Win2k3服务器上,我是其管理员。

我的客户端的部分解决方案是上传
的应用程序文件到服务器以及成员信息和其他相关数据到
SQL服务器。没有诉诸服务器应用程序,知道我的客户对更高级的技术(即FTP)没有信心,我想使用
a安全共享文件夹,我的应用程序将文件复制到
在客户端技能水平和开发时间方面都是最简单的解决方案。

然而,C#/ .NET中的应用程序编程对我来说是新的,并且在
之后perusings System.IO和System.Security.Permissions我似乎仍然无法找到从服务器请求身份验证的方法。

John Wood写道:
Sorry I should have elaborated first. The shared folder is located on a
Win2k3 server equipped with SQL server of which I am the administrator of.

Part of my solution for my client is for an application to upload documents to the server as well as member information and other related data to the SQL server. Without resorting to a server application, knowing that my clients
are not confident with more advanced technology (ie FTP), I figured use of a secure shared folder to which my application will copy the documents to would be the simplest solution in terms of both the client skill level and
development time.

However, appliaction programming in C#/.NET is new to me, and after
perusings System.IO and System.Security.Permissions I still can''t seem to
find a way to request authentication from the server.

"John Wood" wrote:
尝试做一个净使用在那个UNC看看你是否可以访问它
首先..也检查写入权限。这可能是您的NT
用户权限的问题。

-
John Wood
博客: http://dotnetjunkies.com/weblog/johnwood

" BLiTZWiNG" < BL ******* @ discussions.microsoft.com>在消息中写道
新闻:A5 ********************************** @ microsof t.com。 ..
Try doing a "net use" on that UNC to see whether you have access to it
first.. also check write access. This is probably an issue with your NT user permissions.

--
John Wood
Blog: http://dotnetjunkies.com/weblog/johnwood
"BLiTZWiNG" <BL*******@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.com...
当我尝试以下操作时:

System.IO.File.Copy(" C:\\test_read\\test.txt",
" \\\\\\ 192.168.0.5 \\test_write \\test.txt",false)

我收到了UnauthorizedAccessException。

然而,我似乎无法找到如何授权文件副本(即
处理用户/通行证)。

我肯定必须有办法我可以这样做,而无需诉诸于
编写一个服务器应用程序,通过tcp / ip将传输的文件保存到
本地文件夹......

任何人?
When I try the following:

System.IO.File.Copy("C:\\test_read\\test.txt",
"\\\\192.168.0.5\\test_write\\test.txt", false)

I get an UnauthorizedAccessException.

I cannot however, seem to find out how to authorize the file copy (ie.
process the user/pass).

I''m sure there must be a way I can do this without resorting to writing a server application that saves a transmitted file over tcp/ip to a local folder...

Anyone?




这篇关于FileCopy到共享文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆