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

How to split the filename and take a number attached to it

Hi Guys,
I got a vb.net page in which the user is uploading a .doc file and what I need to do is put an _ at the end of the file name if the file is uploaded for the first time and later on if some one edits the same file and upload ,I need to save it with a version number like filename_ 001,002 .... after the _.So can anyone tell me how to use the split function and check from the database whether the file has already been uploaded before or not.Also another problem is that I need to check from the right side of the file name since if the file name is already having a _ other than the one I append,then if the name is scanned from the left side,as in usual case is going to cause problem.Hope anyone can help me with this.
Thanks
Jan 30 '08 #1
5 1224
leoiser
41
Your Question is not clear.

If you want to check/get last uploaded file of

select top 1 UploadFileName from tblUploadFile where UploadFileName like 'filename_%' order by UploadedDate DESC

The above query will give you last uploaded file

in VB.net do a checking
'Assuming u need to check file name start with "myFile_"
Dim sFileName As String = "myFile_"

If dr.HasRows() Then
If dr.Read() Then
sFileName = sFileName + (Convert.ToInt64(Convert.ToString(dr("UploadFileNa me")).Replace(sFileName, "")) + 1).ToString("000")
End If
Else
sFileName = sFileName + "001"
End If


is it met your requirement?

Hi Guys,
I got a vb.net page in which the user is uploading a .doc file and what I need to do is put an _ at the end of the file name if the file is uploaded for the first time and later on if some one edits the same file and upload ,I need to save it with a version number like filename_ 001,002 .... after the _.So can anyone tell me how to use the split function and check from the database whether the file has already been uploaded before or not.Also another problem is that I need to check from the right side of the file name since if the file name is already having a _ other than the one I append,then if the name is scanned from the left side,as in usual case is going to cause problem.Hope anyone can help me with this.
Thanks
Jan 31 '08 #2
kunal pawar
297 100+
You mean want just file name before "_", for ex xyz_001.xxx then u want xyz right ??

If yes then you can split filename by "_" character and u get filename

Or u can generate like query in ur sql statement
Jan 31 '08 #3
Actually what i mean was I need to get the version numbers like 001,002 etc.but if i start slitting the filename from left,then if the filename is having another _ then it wil be a problem right?for eg file_name_001.doc.here since i got 2 _ how can i get the version number 001 as such.
Jan 31 '08 #4
Frinavale
9,735 Expert Mod 8TB
Actually what i mean was I need to get the version numbers like 001,002 etc.but if i start slitting the filename from left,then if the filename is having another _ then it wil be a problem right?for eg file_name_001.doc.here since i got 2 _ how can i get the version number 001 as such.
You have to make sure that the file name is in the format that you expect.
Set a rule stating that the version number must be at the end of the file name and that it is 3 digits long.
Then you can take the last 3 characters in the filename string (excluding the extension of course...).

Check out the methods for the String class.

-Frinny
Jan 31 '08 #5
kunal pawar
297 100+
then take last Item of array and plz trim part of .doc
Feb 1 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Martin Lucas-Smith | last post by:
I am trying to take a string and split it into a filename and a number where the number is what follows the *last* instance of a comma in that string. Split and explode won't work because if the...
12
by: Xah Lee | last post by:
Python Doc Problem Example Quote from: http://docs.python.org/lib/module-os.path.html ---------- split( path) Split the pathname path into a pair, (head, tail) where tail is the last...
3
by: Xah Lee | last post by:
Split File Fullpath Into Parts Xah Lee, 20051016 Often, we are given a file fullpath and we need to split it into the directory name and file name. The file name is often split into a core...
6
by: Ajit | last post by:
I have a tab delimited string and i want to split it to read all the values from the string I tried multiple way but doesn't work with ASP.Net i tried aryData = strData.Split(vbTab) ...
2
by: Curious Joe | last post by:
I have some files that are anywhere from 3GB to 9GB and I need to split them down to a series of smaller files similar to what the "split" command in linux can do. Unfortunately, I do not have...
3
by: najimou | last post by:
Hi everyone I will be having a split database, running on 2 computers via mapped drive. computer "A" will have one front end and the back end located in c: \mydatabse 2 tables have links to...
7
by: AMP | last post by:
Hello, I am trying to split a string at the newline and this doesnt work: String Channel = FileName.Split("\r"); What am I doing wrong? Thanks Mike
3
by: =?Utf-8?B?ZGVlcGFr?= | last post by:
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...
13
by: nivet | last post by:
Hi, I am new to perl programming. I have a requirement to validate the input received from the user with the file and send it to the printer. For Eg: script -o option -p printername -f...
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: 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: 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...
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
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...
0
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...

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.