473,386 Members | 1,827 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,386 software developers and data experts.

file.copy problem

Hi

From my aspx page i am calling one of the console.exe. that exe will copy
the file from network to local webserver. everything hardcoded path. I given
all the permission to that exe. I am getting below error on last line

what am i doing wrong here.

Could not find file "\\laptop02\temp\test.pdf".

thanks
bala
Exe code:

Dim Targetpath As String
Dim sourcepath As String
For Each Arg As String In Args
sourcepath = Arg
Next Arg

sourcepath = "\\laptop02\temp\test.pdf"
Targetpath = "c:\inetpub\wwwroot\temp\"
Dim myFile As FileInfo
Dim myCopiedFile As FileInfo

'check if file exists, if so delete it
If File.Exists(Path:=Targetpath & Path.GetFileName(sourcepath)) Then
File.Delete(Path:=Targetpath & Path.GetFileName(sourcepath))
End If

'get the newly created file
myFile = New FileInfo(fileName:=sourcepath)
Console.WriteLine(sourcepath)
Console.WriteLine(Targetpath)
'overwrite an existing file if need be
myCopiedFile = myFile.CopyTo(destFileName:=Targetpath &
Path.GetFileName(sourcepath), overwrite:=True)
Nov 19 '05 #1
3 1512
Give permissions to the Server\Share as well as the file/folder to the user
that ASP.NET is connecting as.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Bala" wrote:
Hi

From my aspx page i am calling one of the console.exe. that exe will copy
the file from network to local webserver. everything hardcoded path. I given
all the permission to that exe. I am getting below error on last line

what am i doing wrong here.

Could not find file "\\laptop02\temp\test.pdf".

thanks
bala
Exe code:

Dim Targetpath As String
Dim sourcepath As String
For Each Arg As String In Args
sourcepath = Arg
Next Arg

sourcepath = "\\laptop02\temp\test.pdf"
Targetpath = "c:\inetpub\wwwroot\temp\"
Dim myFile As FileInfo
Dim myCopiedFile As FileInfo

'check if file exists, if so delete it
If File.Exists(Path:=Targetpath & Path.GetFileName(sourcepath)) Then
File.Delete(Path:=Targetpath & Path.GetFileName(sourcepath))
End If

'get the newly created file
myFile = New FileInfo(fileName:=sourcepath)
Console.WriteLine(sourcepath)
Console.WriteLine(Targetpath)
'overwrite an existing file if need be
myCopiedFile = myFile.CopyTo(destFileName:=Targetpath &
Path.GetFileName(sourcepath), overwrite:=True)

Nov 19 '05 #2
when you start a process, it runns under the creditials of the creating
process, not thread. generally this is the asp.net account, which is a local
account without network permissions. you have a couople options:

1) change the asp.net account to a domain account with network permissions
to your share.
2) use the CreateProcessAsUser api

-- bruce (sqlwork.com)
"Bala" <Ba**@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
Hi

From my aspx page i am calling one of the console.exe. that exe will copy
the file from network to local webserver. everything hardcoded path. I
given
all the permission to that exe. I am getting below error on last line

what am i doing wrong here.

Could not find file "\\laptop02\temp\test.pdf".

thanks
bala
Exe code:

Dim Targetpath As String
Dim sourcepath As String
For Each Arg As String In Args
sourcepath = Arg
Next Arg

sourcepath = "\\laptop02\temp\test.pdf"
Targetpath = "c:\inetpub\wwwroot\temp\"
Dim myFile As FileInfo
Dim myCopiedFile As FileInfo

'check if file exists, if so delete it
If File.Exists(Path:=Targetpath & Path.GetFileName(sourcepath))
Then
File.Delete(Path:=Targetpath & Path.GetFileName(sourcepath))
End If

'get the newly created file
myFile = New FileInfo(fileName:=sourcepath)
Console.WriteLine(sourcepath)
Console.WriteLine(Targetpath)
'overwrite an existing file if need be
myCopiedFile = myFile.CopyTo(destFileName:=Targetpath &
Path.GetFileName(sourcepath), overwrite:=True)

Nov 19 '05 #3
I created mapping to that networkmachine call X. when i go to permission
properties, i cannot give permission to my local aspnet account. its not
allowing me to do that. bcos the location says that network machine or my
domain. its not showing my local machine.

bala

"Curt_C [MVP]" wrote:
Give permissions to the Server\Share as well as the file/folder to the user
that ASP.NET is connecting as.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Bala" wrote:
Hi

From my aspx page i am calling one of the console.exe. that exe will copy
the file from network to local webserver. everything hardcoded path. I given
all the permission to that exe. I am getting below error on last line

what am i doing wrong here.

Could not find file "\\laptop02\temp\test.pdf".

thanks
bala
Exe code:

Dim Targetpath As String
Dim sourcepath As String
For Each Arg As String In Args
sourcepath = Arg
Next Arg

sourcepath = "\\laptop02\temp\test.pdf"
Targetpath = "c:\inetpub\wwwroot\temp\"
Dim myFile As FileInfo
Dim myCopiedFile As FileInfo

'check if file exists, if so delete it
If File.Exists(Path:=Targetpath & Path.GetFileName(sourcepath)) Then
File.Delete(Path:=Targetpath & Path.GetFileName(sourcepath))
End If

'get the newly created file
myFile = New FileInfo(fileName:=sourcepath)
Console.WriteLine(sourcepath)
Console.WriteLine(Targetpath)
'overwrite an existing file if need be
myCopiedFile = myFile.CopyTo(destFileName:=Targetpath &
Path.GetFileName(sourcepath), overwrite:=True)

Nov 19 '05 #4

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

Similar topics

1
by: Tony George | last post by:
Hi, I'm having a problem using the Copy module on a ClearCase view that's been set as "readonly" (i.e. ct chview -readonly <view tag>). I want to copy a file out of this view and put it in...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
2
by: Pete Davis | last post by:
I'm getting an exception when trying to copy a file. I basically do a File.Copy(source, dest, false); source is the source full path and filename. dest is the destination full path and...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
8
by: luis molina Micasoft | last post by:
it seems that when i do file.copy the svchost.exe is hanged, i mean if i make 40 threads of file.copy , 40 copys of files at same time the system is going down and stop responding, this is when i'm...
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
6
by: elake | last post by:
I found this thread about a pst file in Windows being locked and I am having the same issue. ...
3
by: tshad | last post by:
I have a function that downloads a file to the users computer and it works fine. The problem is that I then want the program to rename the file (file.move) to the same name plus todays date. ...
3
by: =?Utf-8?B?R2FuZXNoYQ==?= | last post by:
Hi I would like to use File.Copy with UNC paths. I have seen this problem reported by others as well. Can i use File.Copy with UNC paths. ie., i would like to copy a file from one of the folder to...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.