473,569 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Path Format not Supported

In an aspx page I run the following C# code-behind:
string filename = null;
filename = txtUpload.Poste dFile.FileName. Trim();
//save the file
txtUpload.Poste dFile.SaveAs(@" C:\home\sites\b obo.com\web\" + filename);

I get the following error: The given path's format is not supported.

Any suggestions as to the proper format for the path would be appreciated.

Thanks,
Jim

Nov 19 '05 #1
5 2447
Check the variable "filename". Name sure it contains what you expect and
nothing more. Also, see what happens if you remove the ".com" from the
path.

"Jim McGivney" <mc****@no-spam.sbcglobal. net> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
In an aspx page I run the following C# code-behind:
string filename = null;
filename = txtUpload.Poste dFile.FileName. Trim();
//save the file
txtUpload.Poste dFile.SaveAs(@" C:\home\sites\b obo.com\web\" + filename);

I get the following error: The given path's format is not supported.

Any suggestions as to the proper format for the path would be appreciated.

Thanks,
Jim

Nov 19 '05 #2
Hi Jim,

Looking at your code here my 5 cents :
your code : filename = txtUpload.Poste dFile.FileName. Trim(); will return
the full filename
e.g c:\test\fileUpl oads\filetouplo ad.txt
hence file name = c:\test\fileUpl oads\filetouplo ad.txt

now when you do
txtUpload.Poste dFile.SaveAs(@" C:\home\sites\b obo.com\web\" + filename)

you are doing (@"C:\home\site s\bobo.com\web\ " +
"c:\test\fileUp loads\filetoupl oad.txt")

hence it will try to save the file in the path :
C:\home\sites\b obo.com\web\c:\ test\fileUpload s\filetoupload. txt

which is invalid format coz of c:\ being twice and hence you getting the
invalid format error

*************** *************** **
Hope this helps,
S.H.A.U.N ™ (M.C.P)
Shounak P
http://blogs.wwwcoder.com/shaunakp
*************** *************** ***

"Jim McGivney" wrote:
In an aspx page I run the following C# code-behind:
string filename = null;
filename = txtUpload.Poste dFile.FileName. Trim();
//save the file
txtUpload.Poste dFile.SaveAs(@" C:\home\sites\b obo.com\web\" + filename);

I get the following error: The given path's format is not supported.

Any suggestions as to the proper format for the path would be appreciated.

Thanks,
Jim

Nov 19 '05 #3
Yuo should double the backslashes
ex: c:\\inetpub\\.. ...

"Jim McGivney" wrote:
In an aspx page I run the following C# code-behind:
string filename = null;
filename = txtUpload.Poste dFile.FileName. Trim();
//save the file
txtUpload.Poste dFile.SaveAs(@" C:\home\sites\b obo.com\web\" + filename);

I get the following error: The given path's format is not supported.

Any suggestions as to the proper format for the path would be appreciated.

Thanks,
Jim

Nov 19 '05 #4
When working with file names and paths it's recommended to use
System.IO.Path-class
For example:
string fName = System.IO.Path. GetFileName(fil ename) //gets only the file
name from full path
It's also recommended to use System.IO.Path. Combine() method to build paths.
So I would do it like:
txtUpload.Poste dFile.SaveAs(Pa th.Combine(@"C: \home\sites\bob o.com\web",
Path.GetFileNam e(filename));


"Shaunak P" wrote:
Hi Jim,

Looking at your code here my 5 cents :
your code : filename = txtUpload.Poste dFile.FileName. Trim(); will return
the full filename
e.g c:\test\fileUpl oads\filetouplo ad.txt
hence file name = c:\test\fileUpl oads\filetouplo ad.txt

now when you do
txtUpload.Poste dFile.SaveAs(@" C:\home\sites\b obo.com\web\" + filename)

you are doing (@"C:\home\site s\bobo.com\web\ " +
"c:\test\fileUp loads\filetoupl oad.txt")

hence it will try to save the file in the path :
C:\home\sites\b obo.com\web\c:\ test\fileUpload s\filetoupload. txt

which is invalid format coz of c:\ being twice and hence you getting the
invalid format error

*************** *************** **
Hope this helps,
S.H.A.U.N ™ (M.C.P)
Shounak P
http://blogs.wwwcoder.com/shaunakp
*************** *************** ***

"Jim McGivney" wrote:
In an aspx page I run the following C# code-behind:
string filename = null;
filename = txtUpload.Poste dFile.FileName. Trim();
//save the file
txtUpload.Poste dFile.SaveAs(@" C:\home\sites\b obo.com\web\" + filename);

I get the following error: The given path's format is not supported.

Any suggestions as to the proper format for the path would be appreciated.

Thanks,
Jim

Nov 19 '05 #5
re:
Yuo should double the backslashes
ex: c:\\inetpub\\.. ...
Actually, no, because he's using the literal @ :

SaveAs(@"C:\hom e\sites\bobo.co m\web\"

The @ means that he does *not* have to double the backslashes.

The correct answer was posted by Shaunak.

The code concatenates two full file paths,
and that is not acceptable as a path format.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Espaol : http://asp.net.do/foros/
=============== =============== ========
"altunbay" <al******@discu ssions.microsof t.com> wrote in message
news:16******** *************** ***********@mic rosoft.com... Yuo should double the backslashes
ex: c:\\inetpub\\.. ...

"Jim McGivney" wrote:
In an aspx page I run the following C# code-behind:
string filename = null;
filename = txtUpload.Poste dFile.FileName. Trim();
//save the file
txtUpload.Poste dFile.SaveAs(@" C:\home\sites\b obo.com\web\" + filename);

I get the following error: The given path's format is not supported.

Any suggestions as to the proper format for the path would be appreciated.

Thanks,
Jim

Nov 19 '05 #6

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

Similar topics

31
3882
by: John Roth | last post by:
I'm adding a thread for comments on Gerrit Holl's pre-pep, which can be found here: http://tinyurl.com/2578q Frankly, I like the idea. It's about time that all of the file and directory stuff in the os module got objectified properly (or at least with some semblance of OO propriety!) In the issues section:
3
3979
by: Mark Urish | last post by:
I want to make sure that a filename is an "absolute path" (ie. has a drive spec. and root, or else is a UNC path) if it isn't already one. Path.GetFullPath seems to do the trick, except there is one thing in the MSDN documentation that makes me nervous. MSDN says that GetFullPath will throw NotSupportedException if its argument contains a...
34
3234
by: Reinhold Birkenfeld | last post by:
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS: /python/nondist/sandbox/path/{path.py,test_path.py} One thing is still different, though: a Path instance won't compare to a regular string.
5
3312
by: Jorg Rdsj | last post by:
Hi I'm trying to use os.path.getmtime to check if a file has been modified. My OS is WinXP. The problem is, that when the os changes from/to daylight savings time, the result is suddenly off by 3600 seconds ie. one hour, even if the file remains the same. I've tried using win32file.GetFileTime, and it reports a consistent number,...
0
6272
by: Rob Meade | last post by:
Hi all, I've written a small app which firstly reads in from an xml config file to set some start parameters. once this is done, it takes the supplied path from the config file, iterates through it finding each .ini file, and parses each one. It basically strips out lines I dont want. When it gets to the end it's supposed to write the...
1
7922
by: WALDO | last post by:
I have a small installation app that I'm building. The user can specify an install path at the command line. How can I ensure that something they put in is valid? What I'm NOT looking for is determining if a path exists. I can accomplish that with Directory.Exists(). I want them to put in a path that may not exist and I'll create it for...
3
4126
by: jason | last post by:
I've been playing around with new (for 2.0) membershp functionality. I was able to build a simple login form that secures a directory on a project I built locally on my development desktop. However, when I attempt to follow the same steps on the remote test server (a website I access via filesystem security accross my lan ).. I get the...
0
1180
by: Developer.Man4 | last post by:
Dear friends :) i need a hand guys i'm implementing a small program to list all virtual directories to the user and give him some facilities to move or delete these files, fine?? i can easily retrieve the list of all virtual directories using the code below
2
6591
by: Darrel | last post by:
(I posted this previously in the wrong NG.) I get this error when trying to run a file upload function on my client's server. It works fine on my local server. I can also create a directory via my code, but not upload a file. I'm using asp.net 1.1 and forms authentication.
0
7710
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
1
7692
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7992
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6313
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5244
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3677
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3666
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
969
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.