473,698 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FileName

Hi
I m facing a strange issue with filename
I am attaching an attachment (may be a notepad file, video file or whatever)
through a dummy customer page (customer.html) using a text box on this page.

I am getting the problem that my code is taking the entire path as file name
instead of that only name of attachment file name e.g. it should take only
attachment file name.
Dim file_coll As HttpFileCollect ion
Dim en_file_coll As IEnumerator
Dim postedfile As HttpPostedFile
file_coll = Request.Files
en_file_coll = file_coll.GetEn umerator

Do While en_file_coll.Mo veNext

postedfile = file_coll.Item( i)

If postedfile.File Name.Length 64 Then

Throw New local_exception ("Filename too long " & postedfile.File Name)
Exit Do
End If
This postedfile.File Name is coming as “C:\Documents and
Settings\wfmadm in\Desktop\test AttachmentFiles \att3.txt" instead of att3.txt

Is there any way to handle it? The file can be of any type (means *.text
file or *.pdf file or whatever and also it can be attached from any folder,
any location etc.)

Kindly help me

Thanks,
Deepak
+919886735837
kr**********@ho tmail.com

Jun 27 '08 #1
3 1690
It is designed like this. FileInfo class provides a bunch of properties for
various parts of file name. With them you can easily take the parts you
want.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"deepak" <de****@discuss ions.microsoft. comwrote in message
news:4A******** *************** ***********@mic rosoft.com...
Hi
I m facing a strange issue with filename
I am attaching an attachment (may be a notepad file, video file or
whatever)
through a dummy customer page (customer.html) using a text box on this
page.

I am getting the problem that my code is taking the entire path as file
name
instead of that only name of attachment file name e.g. it should take only
attachment file name.
Dim file_coll As HttpFileCollect ion
Dim en_file_coll As IEnumerator
Dim postedfile As HttpPostedFile
file_coll = Request.Files
en_file_coll = file_coll.GetEn umerator

Do While en_file_coll.Mo veNext

postedfile = file_coll.Item( i)

If postedfile.File Name.Length 64 Then

Throw New local_exception ("Filename too long " &
postedfile.File Name)
Exit Do
End If
This postedfile.File Name is coming as "C:\Documen ts and
Settings\wfmadm in\Desktop\test AttachmentFiles \att3.txt" instead of
att3.txt

Is there any way to handle it? The file can be of any type (means *.text
file or *.pdf file or whatever and also it can be attached from any
folder,
any location etc.)

Kindly help me

Thanks,
Deepak
+919886735837
kr**********@ho tmail.com

Jun 27 '08 #2
hi,

i had a problem as to find file extension and i have solved that by this C#
code; may give you an opinion...

string resimDosyaUzant isi =
resim1FU.FileNa me.Substring(re sim1FU.FileName .LastIndexOf(". ") + 1, 3);

"deepak" <de****@discuss ions.microsoft. com>, iletisinde şunu yazdı,
news:4A******** *************** ***********@mic rosoft.com...
Hi
I m facing a strange issue with filename
I am attaching an attachment (may be a notepad file, video file or
whatever)
through a dummy customer page (customer.html) using a text box on this
page.

I am getting the problem that my code is taking the entire path as file
name
instead of that only name of attachment file name e.g. it should take only
attachment file name.
Dim file_coll As HttpFileCollect ion
Dim en_file_coll As IEnumerator
Dim postedfile As HttpPostedFile
file_coll = Request.Files
en_file_coll = file_coll.GetEn umerator

Do While en_file_coll.Mo veNext

postedfile = file_coll.Item( i)

If postedfile.File Name.Length 64 Then

Throw New local_exception ("Filename too long " &
postedfile.File Name)
Exit Do
End If
This postedfile.File Name is coming as “C:\Documents and
Settings\wfmadm in\Desktop\test AttachmentFiles \att3.txt" instead of
att3.txt

Is there any way to handle it? The file can be of any type (means *.text
file or *.pdf file or whatever and also it can be attached from any
folder,
any location etc.)

Kindly help me

Thanks,
Deepak
+919886735837
kr**********@ho tmail.com
Jun 27 '08 #3

"Tahir" <ku*********@gm ail.comwrote in message
news:84******** *************** ***********@mic rosoft.com...
hi,

i had a problem as to find file extension and i have solved that by this
C# code; may give you an opinion...

string resimDosyaUzant isi =
resim1FU.FileNa me.Substring(re sim1FU.FileName .LastIndexOf(". ") + 1, 3);

"deepak" <de****@discuss ions.microsoft. com>, iletisinde şunu yazdı,
news:4A******** *************** ***********@mic rosoft.com...
>Hi
I m facing a strange issue with filename
I am attaching an attachment (may be a notepad file, video file or
whatever)
through a dummy customer page (customer.html) using a text box on this
page.

I am getting the problem that my code is taking the entire path as file
name
instead of that only name of attachment file name e.g. it should take
only
attachment file name.
Dim file_coll As HttpFileCollect ion
Dim en_file_coll As IEnumerator
Dim postedfile As HttpPostedFile
file_coll = Request.Files
en_file_coll = file_coll.GetEn umerator

Do While en_file_coll.Mo veNext

postedfile = file_coll.Item( i)

If postedfile.File Name.Length 64 Then

Throw New local_exception ("Filename too long " &
postedfile.Fil eName)
Exit Do
End If
This postedfile.File Name is coming as “C:\Documents and
Settings\wfmad min\Desktop\tes tAttachmentFile s\att3.txt" instead of
att3.txt

Is there any way to handle it? The file can be of any type (means *.text
file or *.pdf file or whatever and also it can be attached from any
folder,
any location etc.)

Kindly help me

Thanks,
Deepak
+91988673583 7
kr**********@ho tmail.com
Look at System.IO.Path. There are all the functions (no rewriting
required) to get file names, extensions etc.

LS

Jun 27 '08 #4

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

Similar topics

3
6796
by: S.W. Rasmussen | last post by:
With the risk of being accused of multi-posting I would like to draw the attention to a serious visual basic/windows issue discussed in the microsoft.public.vb.bugs newsgroup. As pointed out below by Norman Diamond the bug may result in loss of data when saving files with the standard common dialog control. Norman Diamond describes the problem as follows: ---------- In VB6 SP6, VB6 SP5, and possibly others, the common dialog box...
11
3235
by: hokiegal99 | last post by:
How would I determine if a filename is greater than a certain number of characters and then truncate it to that number? For example a file named XXXXXXXXX.txt would become XXXXXX fname = files if fname > 6 print fname Thanks!!!
4
1906
by: Michael | last post by:
All, I'll asked a question but I was not detailed (clear) enough for people to help so I'll retry. I have a cgi script pass a variable from one page to the next. The 'receiving' page replaces this variable (in this case %filename%) with whatever was passed. This works fine when the page is called from the cgi script because it has
10
13064
by: Brian Gruber | last post by:
Hi, I'm looking for a way to rename a whole directory of files in short order. The files in the directory have different lengths, however all of them end with _xxxx the x's represent a randomly generated number from a program that I saved from. So I need to find a way that I can quickly remove the underscore and the last 4 numbers from the filename without changing anything else. I can't set a max length to the file becuase the filename's...
8
8554
by: Lad | last post by:
Hello, what is a way to get the the extension of a filename from the path? E.g., on my XP windows the path can be C:\Pictures\MyDocs\test.txt and I would like to get the the extension of the filename, that is here txt I would like that to work on Linux also
12
1976
by: IamIan | last post by:
I searched the archives but couldn't find anyone else with this problem. Basically I'm grabbing all ASCII files in a directory and doing geoprocessing on them. I need to calculate a z-factor based on the latitude of the ASCII file being worked on, which is in the filename. If I type in the code manually it works and reads the latitude value from the ASCII filename, but when run within ArcGIS it crashes when it gets to int(LatString)....
4
2500
by: B Squared | last post by:
I'm trying to pass a filename (which is a jpeg image) to a php function / file so that it will display. I know that its simple to get PHP to display an image hardcoding in the filename. For example, an href to this: <?php header("content-type:image/jpeg"); $filename = "image_file.jpg"; $im=ImageCreateFromJPEG($filename); ImageJPEG($im);
10
1779
by: Steve | last post by:
I am trying to create a downloader which will bypass the saveas box in the WebBrowser control. I have the file downloading, but I don't know what the filename is that is being passed through the stream. Is their a way to determine what the file name is so that I can execute the appropriate functionality of the extensions. The stream is created dynamically so I cannot capture the filename straight from the URL. Thanks STeve
0
2674
by: jinnareddy | last post by:
Hi, I'm unable to download a file that is having a 2-byte char in its name (e.g.テ) using force download option. Though, am able to download file names involving ASCII chars. I have tried URL encoding too, but with no success. Can someone provide details on how to handle the 2-byte char URLs and download the files? Appreciate your suggestions/help in resolving it. Here is my code:
12
4256
by: vj | last post by:
I am using Borland C++. I run a program which generates output data files, say 'Voltage.dat', 'Current.dat'. I have a variable in my code (say N), and for various values of N (for each value of N), I generate these output data files. After running the program once for a given value of N (say N equal to 1) and when the programme is finished, I manually append the generated filename with the value of N, such as 'Voltage_N1.dat',...
0
8604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9028
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5860
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2001
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.