473,385 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Copy file problem !!

Dear All,
I want to use web form to upload my file and copy the file to another
machine.
I can upload the file, but when I copy the file(file.CopyTo(".....", true))
to another machine(map network driver), it failed(error message : login
failed......).
So.... how should I do if I want the upload file can copy to another
machine. Thanks !!
--
Paul

Nov 15 '05 #1
2 5937
> I want to use web form to upload my file and copy the file to another
machine.
I can upload the file, but when I copy the file(file.CopyTo(".....", true)) to another machine(map network driver), it failed(error message : login
failed......).
So.... how should I do if I want the upload file can copy to another
machine. Thanks !!

I do not know anything about webforms but I do know about .NET security.
Standard .NET security defaults not to accept any network connection.
So "file open" on a network drive will fail while on the local drive it will
succeede.
You have to tell the program that he must have access to the network too.

In C# you have an assembly.cs file and I added these (just copied and
pasted, I think that "ZoneIdentityPermission" and maybe "FileIOPermission"
would be enough)
----------------
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;

[assembly:SecurityPermission(SecurityAction.Request Minimum,
UnmanagedCode=true)] // Request to run unmanaged code
[assembly:FileIOPermission(SecurityAction.RequestMi nimum,
Unrestricted=true)] // Request complete File IO functionality
[assembly:RegistryPermission(SecurityAction.Request Minimum, All="*")] //
Request complet access to the registery key
[assembly:ZoneIdentityPermission(SecurityAction.Req uestMinimum,Zone=Security
Zone.NoZone)] // Request unrestricted zone
-------------------

Nov 15 '05 #2
You web application doesn't have the necessary privileges to access the
remote share.
Here are a number of options to solve this:

1) You can run your web application using alternate credentials by changing
the machine.config file
<Process ....model - userName, password
2) You can create a new logon session by calling Win32's LogonUser API and
impersonate (search the KB for samples).
3) You can impersonate the base client, but this requires a correctly
configured Kerberos realm and delegation.
Other options are using calling a COM+ server type application running with
fixed (valid) credentials for the file copy operation, or using remoting to
call the copy operation from a windows service running with fixed
credentials.

Willy.

"Paul" <pa**@ltl-j.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Dear All,
I want to use web form to upload my file and copy the file to another
machine.
I can upload the file, but when I copy the file(file.CopyTo(".....",
true))
to another machine(map network driver), it failed(error message : login
failed......).
So.... how should I do if I want the upload file can copy to another
machine. Thanks !!
--
Paul

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Grey | last post by:
I have a ASP.NET web application which is required to copy file from windows server to Novell Netware server. I have used impersonation to connect to Netware server. The application works fine when...
9
by: MAF | last post by:
Does anyone know why in 2005 I might be getting this error everytime I try and recompile? Error 226 Unable to copy file "obj\Debug\myfile.dll" to "bin\Debug\myfile.dll". The process cannot...
3
by: MAF | last post by:
Does anyone know why in 2005 I might be getting this error everytime I try and recompile? Error 226 Unable to copy file "obj\Debug\myfile.dll" to "bin\Debug\myfile.dll". The process cannot...
5
by: Standist | last post by:
I want install software on PC in my local network. First I want copy file to the PC through default share like c$ or d$ on the PC. Then install the software through wmi. I have the administrator...
1
by: vandanaj | last post by:
hi everyone i want to know how to copy file in asp thanx in advance
0
by: Pivalig | last post by:
Hello, i try to copy file from Pocket PC to network printer using this code : destination = "\\\\pc1\\ep1000\\Bill.txt"; File.Copy("\\Program Files\\MobileKhelner\\Bill.txt", destination); ...
9
rizwan6feb
by: rizwan6feb | last post by:
Hello everybody. I need help on how to use copy function to copy file from one computer to another ( or any other way i can copy the file). The computers are on a local network.
1
by: Irrigho5 | last post by:
i have the open file function just need help with the copy file function and main Ask for a source filename and a target filename. Then copy the source file to the target file using the...
2
by: foss | last post by:
hi all, I am not able to copy file from a directory in the server to another directory. Here, the source is outside the web root directory and the destination is inside the web root directory. ...
1
by: rajibdotnet | last post by:
Till Date, I find no solution to the problem below. Unable to copy file "obj\Debug\Tax2010.dll" to "bin\Tax2010.dll". The process cannot access the file 'bin\Tax2010.dll' because it is being used...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.