Discussion:
FileUpload
Lior Levy
2007-09-03 18:15:37 UTC
Permalink
Hello,



I am trying to Upload & save a file in the web server, When I specify a physical path like:

FileUpload1.SaveAs("C:\Files\" & FileUpload1.FileName))

It works fine.



But when I map the drive & use something like this:

FileUpload1.SaveAs("F:\foldername\" & FileUpload1.FileName))



I get the error:

Could not find a part of the path F:\foldername\globalsProc.doc'.

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\foldername\globalsProc.doc'.



If I use this:

FileUpload1.SaveAs("\\comuterName\D$\foldername\" & FileUpload1.FileName))



I get the error:

The SaveAs method is configured to require a rooted path, and the path '\\comuterName\d$\foldername\globalsProc.doc'' is not rooted.



I have Full NTFS control for the user on the drive.





Any idea?

Thanks in advance,

Lior.










===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Chris Anderson
2007-09-03 23:35:47 UTC
Permalink
How are you mapping the drive?
If you are mapping it from your personal account, other users (for example, the ASPNET user that the web server is using) do not see the mapping


-----Original Message-----
From: "Lior Levy"<***@EXCHANGE.BGU.AC.IL>
Sent: 03/09/07 18:16:10
To: "DOTNET-***@DISCUSS.DEVELOP.COM"<DOTNET-***@DISCUSS.DEVELOP.COM>
Subject: [DOTNET-WEB] FileUpload

Hello,



I am trying to Upload & save a file in the web server, When I specify a physical path like:

FileUpload1.SaveAs("C:\Files\" & FileUpload1.FileName))

It works fine.



But when I map the drive & use something like this:

FileUpload1.SaveAs("F:\foldername\" & FileUpload1.FileName))



I get the error:

Could not find a part of the path F:\foldername\globalsProc.doc'.

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\foldern



[Message truncated. Tap Edit->Mark for Download to get remaining portion.]

-----Unmodified Original Message-----
Hello,



I am trying to Upload & save a file in the web server, When I specify a physical path like:

FileUpload1.SaveAs("C:\Files\" & FileUpload1.FileName))

It works fine.



But when I map the drive & use something like this:

FileUpload1.SaveAs("F:\foldername\" & FileUpload1.FileName))



I get the error:

Could not find a part of the path F:\foldername\globalsProc.doc'.

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\foldername\globalsProc.doc'.



If I use this:

FileUpload1.SaveAs("\\comuterName\D$\foldername\" & FileUpload1.FileName))



I get the error:

The SaveAs method is configured to require a rooted path, and the path '\\comuterName\d$\foldername\globalsProc.doc'' is not rooted.



I have Full NTFS control for the user on the drive.





Any idea?

Thanks in advance,

Lior.










===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Lior Levy
2007-09-04 06:55:13 UTC
Permalink
Chris, thank you for the answer.
So what do you suggest?
How can I upload a file from a web server & save it on another server?

Lior.


-----Original Message-----
From: Discussion of building .NET applications targeted for the Web [mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Chris Anderson
Sent: Tuesday, September 04, 2007 1:36 AM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-WEB] FileUpload

How are you mapping the drive?
If you are mapping it from your personal account, other users (for example, the ASPNET user that the web server is using) do not see the mapping


-----Original Message-----
From: "Lior Levy"<***@EXCHANGE.BGU.AC.IL>
Sent: 03/09/07 18:16:10
To: "DOTNET-***@DISCUSS.DEVELOP.COM"<DOTNET-***@DISCUSS.DEVELOP.COM>
Subject: [DOTNET-WEB] FileUpload

Hello,



I am trying to Upload & save a file in the web server, When I specify a physical path like:

FileUpload1.SaveAs("C:\Files\" & FileUpload1.FileName))

It works fine.



But when I map the drive & use something like this:

FileUpload1.SaveAs("F:\foldername\" & FileUpload1.FileName))



I get the error:

Could not find a part of the path F:\foldername\globalsProc.doc'.

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\foldern



[Message truncated. Tap Edit->Mark for Download to get remaining portion.]

-----Unmodified Original Message-----
Hello,



I am trying to Upload & save a file in the web server, When I specify a physical path like:

FileUpload1.SaveAs("C:\Files\" & FileUpload1.FileName))

It works fine.



But when I map the drive & use something like this:

FileUpload1.SaveAs("F:\foldername\" & FileUpload1.FileName))



I get the error:

Could not find a part of the path F:\foldername\globalsProc.doc'.

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\foldername\globalsProc.doc'.



If I use this:

FileUpload1.SaveAs("\\comuterName\D$\foldername\" & FileUpload1.FileName))



I get the error:

The SaveAs method is configured to require a rooted path, and the path '\\comuterName\d$\foldername\globalsProc.doc'' is not rooted.



I have Full NTFS control for the user on the drive.





Any idea?

Thanks in advance,

Lior.










===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
David Cameron
2007-09-04 06:07:26 UTC
Permalink
Try using UNC paths (\\<server name>\<share name>). You want to make
sure that the account your code is running under has permission to
access that share.

regards
David
Post by Lior Levy
Chris, thank you for the answer.
So what do you suggest?
How can I upload a file from a web server & save it on another server?
Lior.
-----Original Message-----
Sent: Tuesday, September 04, 2007 1:36 AM
Subject: Re: [DOTNET-WEB] FileUpload
How are you mapping the drive?
If you are mapping it from your personal account, other users (for example, the ASPNET user that the web server is using) do not see the mapping
-----Original Message-----
Sent: 03/09/07 18:16:10
Subject: [DOTNET-WEB] FileUpload
Hello,
FileUpload1.SaveAs("C:\Files\" & FileUpload1.FileName))
It works fine.
FileUpload1.SaveAs("F:\foldername\" & FileUpload1.FileName))
Could not find a part of the path F:\foldername\globalsProc.doc'.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\foldern
[Message truncated. Tap Edit->Mark for Download to get remaining portion.]
-----Unmodified Original Message-----
Hello,
FileUpload1.SaveAs("C:\Files\" & FileUpload1.FileName))
It works fine.
FileUpload1.SaveAs("F:\foldername\" & FileUpload1.FileName))
Could not find a part of the path F:\foldername\globalsProc.doc'.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\foldername\globalsProc.doc'.
FileUpload1.SaveAs("\\comuterName\D$\foldername\" & FileUpload1.FileName))
The SaveAs method is configured to require a rooted path, and the path '\\comuterName\d$\foldername\globalsProc.doc'' is not rooted.
I have Full NTFS control for the user on the drive.
Any idea?
Thanks in advance,
Lior.
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Efran Cobisi
2007-09-04 12:10:32 UTC
Permalink
[I've just answered the same question in the Advanced .NET list but I'm
replying here too for readers convenience.]

Hi Lior,

Please avoid cross posting...

To save the content of your uploaded file you could simply bypass the
checks performed by the SaveAs() method and manually persist its data.
Here's a short code fragment (C#):

using (FileStream stream = new
FileStream("\\computerName\sharedPath\test.bin", FileMode.Create))
FileUpload1.InputStream.WriteTo(stream);

Also pay attention to the fact that volume shares (C$, D$, etc) are by
default visibile to administrators only, if I recall correctly.
Hope this helps.

--
Efran Cobisi
http://www.cobisi.com
Post by Lior Levy
Chris, thank you for the answer.
So what do you suggest?
How can I upload a file from a web server & save it on another server?
Lior.
-----Original Message-----
Sent: Tuesday, September 04, 2007 1:36 AM
Subject: Re: [DOTNET-WEB] FileUpload
How are you mapping the drive?
If you are mapping it from your personal account, other users (for example, the ASPNET user that the web server is using) do not see the mapping
-----Original Message-----
Sent: 03/09/07 18:16:10
Subject: [DOTNET-WEB] FileUpload
Hello,
FileUpload1.SaveAs("C:\Files\" & FileUpload1.FileName))
It works fine.
FileUpload1.SaveAs("F:\foldername\" & FileUpload1.FileName))
Could not find a part of the path F:\foldername\globalsProc.doc'.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\foldern
[Message truncated. Tap Edit->Mark for Download to get remaining portion.]
-----Unmodified Original Message-----
Hello,
FileUpload1.SaveAs("C:\Files\" & FileUpload1.FileName))
It works fine.
FileUpload1.SaveAs("F:\foldername\" & FileUpload1.FileName))
Could not find a part of the path F:\foldername\globalsProc.doc'.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\foldername\globalsProc.doc'.
FileUpload1.SaveAs("\\comuterName\D$\foldername\" & FileUpload1.FileName))
The SaveAs method is configured to require a rooted path, and the path '\\comuterName\d$\foldername\globalsProc.doc'' is not rooted.
I have Full NTFS control for the user on the drive.
Any idea?
Thanks in advance,
Lior.
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Mark Aurit
2007-09-05 15:24:08 UTC
Permalink
I use a base page (which inherits from System.Web.UI.Page) behind my
.aspx, and I have a similar one behind my masterpage (inheriting from
System.Web.UI.MasterPage). Im seeing the need by both to use many of
the same functions, but Im assuming I cant use the same for both. Ive
played the cut-and-paste inheritance in the paste, and am not a fan.
Does anyone have any advice for a good strategy to do this? (share the
same functions between different base pages)
Thanks very much
Mark

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Efran Cobisi, cobisi.com
2007-09-05 17:27:39 UTC
Permalink
Mark,

I'd rather extract the required functionalities and put them in another
class, which I'd use in both my base and master pages: this one would be
the best approach to follow.
It is possible, however, to have the page access its associated master
page and vice versa. Have a look to the Master property of the Page
class and to the Page property of the MasterPage class respectively.

Hope this helps.

--
Efran Cobisi
http://www.cobisi.com
Post by Mark Aurit
I use a base page (which inherits from System.Web.UI.Page) behind my
.aspx, and I have a similar one behind my masterpage (inheriting from
System.Web.UI.MasterPage). Im seeing the need by both to use many of
the same functions, but Im assuming I cant use the same for both. Ive
played the cut-and-paste inheritance in the paste, and am not a fan.
Does anyone have any advice for a good strategy to do this? (share the
same functions between different base pages)
Thanks very much
Mark
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Mark Aurit
2007-09-07 15:10:42 UTC
Permalink
Thanks.
As Ive thought about it, the items I particularly have "issues" with are
those that access state, be it in session or in cookies. I use a single
function for this (see pseudo code below) and since I use it extensively
in my apps it logically goes into the base class, but either base class
(web pages or master pages) may need it. And since these base classes
inherit from different SYSTEM.WEB.UI classes, I am not clear on the
cleanest way to do this.

public string GetState(enumStateId eId)
{
if (eId=enumStateId.PersonName)
return personNameFromSessionSrate;
else if (eId=enumStateId.PersonId)
return personIdFromSessionState;
}
Post by Efran Cobisi, cobisi.com
Mark,
I'd rather extract the required functionalities and put them in another
class, which I'd use in both my base and master pages: this one would be
the best approach to follow.
It is possible, however, to have the page access its associated master
page and vice versa. Have a look to the Master property of the Page
class and to the Page property of the MasterPage class respectively.
Hope this helps.
--
Efran Cobisi
http://www.cobisi.com
Post by Mark Aurit
I use a base page (which inherits from System.Web.UI.Page) behind my
.aspx, and I have a similar one behind my masterpage (inheriting from
System.Web.UI.MasterPage). Im seeing the need by both to use many of
the same functions, but Im assuming I cant use the same for both. Ive
played the cut-and-paste inheritance in the paste, and am not a fan.
Does anyone have any advice for a good strategy to do this? (share the
same functions between different base pages)
Thanks very much
Mark
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Efran Cobisi, cobisi.com
2007-09-09 14:03:49 UTC
Permalink
Hi Mark,

Why don't have a StateManager (or sort of) class? You could have all of
the required logic placed inside it and all of the classes wich need it
could just use istances of that class.
Hope this helps.

--
Efran Cobisi
http://www.cobisi.com
Post by Mark Aurit
Thanks.
As Ive thought about it, the items I particularly have "issues" with are
those that access state, be it in session or in cookies. I use a single
function for this (see pseudo code below) and since I use it extensively
in my apps it logically goes into the base class, but either base class
(web pages or master pages) may need it. And since these base classes
inherit from different SYSTEM.WEB.UI classes, I am not clear on the
cleanest way to do this.
public string GetState(enumStateId eId)
{
if (eId=enumStateId.PersonName)
return personNameFromSessionSrate;
else if (eId=enumStateId.PersonId)
return personIdFromSessionState;
}
Post by Efran Cobisi, cobisi.com
Mark,
I'd rather extract the required functionalities and put them in another
class, which I'd use in both my base and master pages: this one would be
the best approach to follow.
It is possible, however, to have the page access its associated master
page and vice versa. Have a look to the Master property of the Page
class and to the Page property of the MasterPage class respectively.
Hope this helps.
--
Efran Cobisi
http://www.cobisi.com
Post by Mark Aurit
I use a base page (which inherits from System.Web.UI.Page) behind my
.aspx, and I have a similar one behind my masterpage (inheriting from
System.Web.UI.MasterPage). Im seeing the need by both to use many of
the same functions, but Im assuming I cant use the same for both. Ive
played the cut-and-paste inheritance in the paste, and am not a fan.
Does anyone have any advice for a good strategy to do this? (share the
same functions between different base pages)
Thanks very much
Mark
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Loading...