.net - Incrementing The Filename?
Jun 7, 2011
Possible Duplicate: Way to get unique filename if specified filename already exists (.NET)Have a look at the following code:
Dim counter As Integer = 0
While System.IO.File.Exists("C:DesktopSample.xls")
counter = counter + 1
[code].....
View 5 Replies
ADVERTISEMENT
Jul 1, 2009
Quick query...I'm trying to scan a long string and return any values that occur between the tags <FileName> and </FileName> I've got a bit of code here to use regular expressions to return the position of the occurunces of both substrings..Just wanted to find out if there is any way to scan for both substrings within one loop (as im currently doing 2, one for the first substring and one for the 2nd) so I can use something along these lines:
ringlist = Mid(XMLRESP, (startloc + 1), (endloc - 1))
MsgBox(ringlist)
to msg box the value between the substrings...either that or another approach to return the value between the 2 substrings (it can be of variable length)
Dim patternstart As String = "<FileName>"
Dim patternend As String = "</FileName>"
Dim matchesstart As MatchCollection = Regex.Matches(XMLRESP, patternstart)
[code].....
View 3 Replies
Oct 17, 2010
How would I do that? Sample code is below that demonstrated that the file I opened contained the full path and file name.
I want to extract just the path and serialize that to the user.config file as a UserSetting value. Then next time the user opens the dialog box, it uses that saved path string to go immediately to the location previously used.
If openFileDialog1.ShowDialog() = DialogResult.OK Then
Properties.Settings.Default.persistConnectionType = openFileDialog1.FileName
Properties.Settings.Default.Save();
[Code].....
View 3 Replies
May 27, 2009
I have a Listview on my form with different files. I can selet a file en open it with the proces start method. To open the file i use the OpenFileDialog method and select the filename. This work very good. With the code below.
My question is if there is a method to get the selected file without using the OpenFileDialog Box. So when i dubbelclick the selected file the proces will start with open the selected file. Something like:
proc.StartInfo.FileName = Me.SelectedCell.FileName
instead of proc.StartInfo.FileName = Me.OpenFileDialog1.FileName
PS) May be i can preduce the Filename using the OpenFileDialog method on the background.
Private Sub ListView1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDoubleClick
If Me.OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
[Code]....
View 8 Replies
Jun 26, 2009
how do you transform an address like "file:///d:filename.ext" in "d:filename.ext"
without dirty string manipulation??
View 4 Replies
Jul 18, 2010
I'm trying to increase the value of a registry entry by 1
HKLMSoftwareMyApp
Key = Test
Value +1
[Code]....
View 2 Replies
Jan 27, 2011
i'm doing this for auto incrementing i called the last value in a row from a database for say, its p-0004 what i wanna do is take p-0004 and add 1 into it to make it p-0005 sorry for my stupidity, i tried using the trim method i used in vb 6 but there was an error like "read only property" something
View 10 Replies
Aug 16, 2011
i'm doing this for auto incrementingi called the last value in a row from a databasefor say, its p-0004what i wanna do is take p-0004 and add 1 into it to make it p-0005sorry for my stupidity, i know this is a noobie question but hey, i'm a noob
View 12 Replies
Aug 5, 2011
What is the += used in this code doing? Is that incrementing the loop?
Public Class Form1
02
Public Structure Family
[CODE]..........................
View 2 Replies
Jul 11, 2011
I am trying to make a simple port scanner to scan a rang of IP's so like 192.168.4.245 to 192.168.5.100. I am using Visual Basic.Net 2010 and am having trouble converting the IP from a String to a Long so that I can increment it and convert it back to a String. For some reason VB.Net 2010 doesn't include the winsock controller and therefore I am having problems finding a method that works similar to inet_addr() which makes conversion much easier. I found an example on one of the forms here
Code:
Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click
[code]....
View 3 Replies
Feb 1, 2010
When you access a subroutine by one or more other subroutines each time the variables are zeroed like 'n' below. How can I keep n saved so main can increment n each time.
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
[Code]....
View 3 Replies
Jun 20, 2009
I've been looking into this problem for a few days now and i can't find exactly the code that i want.I want to run a procedure using an incrementing matrix. If the Matrix that was used is correct then the correct matrix is shown.
the process is get first iteration process if incorrect repeat with next iteration correct end the issue is with the iterations and breaking out of them the matrix length, depth and iteration step can vary.
this is best shown in an example
length = 5
high = 3
low = 0
step 1
the iterations should look like
[Code]...
View 5 Replies
Feb 17, 2009
I have created a table with the following fields
loan_id (PK)
loan_date
loan_return_date
loan_user (FK)
i have set the loan_id column to increment in steps of 1, but when i add a column in visual studio 2008 express it auto increments in minus steps -1 -2 -3. it increments in positive numbers?
View 5 Replies
Nov 15, 2011
I have some nested objects arranged like this:
Process
Persons
Workflows
Tasks
So you have one Process. Then multiple Persons can be added to and multiple WorkFlows can be added Process as well. Multiple Tasks can be added to each WorkFlow but I need a way to tie which Person is doing each task. I basically need a way that for each Person added to the Process it, in it's constructor, assigns a Person.ID property that can then be assigned into each Task's PersonID property...
Dim myProcess as New Process()
Dim myPerson as New Process.Person()
myProcess.AddPerson(myPerson)
[code]....
View 2 Replies
Jun 21, 2010
I would like to know the coding behind incrementing a progress bar using a timer.
View 4 Replies
Nov 18, 2010
i do have a table with 3 cols, 2 of those will visible for users to enter data, the last one is needed to get inserted as the next number of the previous number.
i use the following query for insert command ,
INSERT INTO [Headers]
(GrpId, GrpName, Number)
Select (Select Case when Max(GrpId) = Null then 1 else Max(GrpId)+ 1 end from [Headers]),
[Code]....
View 8 Replies
Mar 10, 2009
I am doing a school project (in programming) on security, and i am focussing on MD5 hashing, this is a used way to store passwords, usernames etc. since i can't really be reversed..Now since i know that MD5 hashes are always 32 byte long there must be a limited number of different "hashes" even though 32 chars with 16 combinations each is a LOT of combos..Now, i will try to make a program where you put in a 32 byte hash and then, by using the principle above with limited hash amounts, try to find ANY string that matches the hash.I have already got code on how to create the MD5 hash but i need to know how to make the strings...it should hash:chr(1)chr(2)...chr(255)thenchr(1) & chr(1)[code]
View 4 Replies
Apr 7, 2010
why my counter is not working properly. It starts by counting all of the files in a directory and everything is set to 0 initially at the start of the program. For some reason when I debug it in certain places the counter increments correctly but with no debugging and once it reaches my DoSql function the counter is not set to the correct number of files anymore.. Below is my code, filesRemaining should be initially set to the number of files then decrement everytime.. when I debug this method itself it works fine but say I put a debug point elsewhere or don't debug at all the counter is not right.
'Declare global variables
Dim fileNumber As Integer = 1
Dim arrayPosition As Integer = 0
Dim changeType As Integer = 0
[code]....
View 1 Replies
Dec 1, 2009
[Code]...
I am trying to replace tasks.IndexOf(t) + 1 with something a little simpler. Is there any built in functionality for this? Hrmm xml literals do not seem to translate well on here....
View 3 Replies
Sep 8, 2010
I have code that increments an array of numbers. However, due to performance issues, I need to optimize it.
Here is the code:
Public Sub increment(ByRef Index() As UInt16)
Dim N As Integer = Index.Length - 1
If (Index(0) = 65535) Then
Index(0) = 0
[Code] .....
View 18 Replies
Jul 23, 2009
I'm trying to weave a .NET performance counter into an application. When I call the incrementBy(value) method on my avg performance counter it is changing the RawValue of my base counter by value as well. I checked the variable names and think everything is correct. Then when I call increment() on my base counter it adds 1 to the rawvalue of the avgcounter as well as incrementing the base counter... adding insult to injury!
In code I'm using two different counters to measure the time a merge sort I wrote takes. I have a instantaneous counter for the elapsed time of the sort and an average counter.
Dim timePiece As New Stopwatch()
timePiece.Start()
MergeSort()
timePiece.Stop()
[Code] .....
I think I may be using the counters wrong, but why does changing the rawvalue of the average seem to also change the rawvalue of the base? i dont think that's supposed to happen.
View 1 Replies
Apr 25, 2012
I am coding an invoicing application. The user should be able to add a new line to the billing section of the invoice by selecting a product from a ComboBox, which subsequently fills out various other fields (price, description, etc) based on the selected product.
My problem is this: When the user adds a product, I would like the program to automatically generate a new line for the next product. It seems like the only way to accomplish this would be to create a new set of controls with an incremented name, i.e. Product1, Price1, Desc1 for the first product, Product2, Price2, Desc2 for the second product, etc. Is this possible, or am I going about it all wrong?
View 1 Replies
Mar 30, 2009
I have a legacy data table in SQL Server 2005 that has a PK with no identity/autoincrement and no power to implement one. As a result, I am forced to create new records in ASP.NET manually via the ole "SELECT MAX(id) + 1 FROM table"-before-insert technique.Obviously this creates a race condition on the ID in the event of simultaneous inserts.
What's the best way to gracefully resolve the event of a race collision? I'm looking for VB.NET or C# code ideas along the lines of detecting a collision and then re-attempting the failed insert by getting yet another max(id) + 1. Can this be done?
View 7 Replies
May 7, 2012
I have a piece of JQuery AJAX that calls a VB.NET code-behind (class) that returns string data. It grabs some latest stats on a particular server. Now the code works, but the first time I press the refresh button data is returned and the alert "Refreshed" is shown on screen.
But if I press it again, the alert box "Refreshed" is shown twice, I click again three times! and on and on, until the time-out kicks in.It seems to be coming from the AJAX call and no where else. I'm at a loss at what could be calling this, I've tried deleting the data returned after success but no joy.
function RefreshServer(btn,div,id,ip) {
$('#aRefresh'+id).html("<img src=images/refreshServer.gif border=0 align=absmiddle />");
$("#"+btn).click(function() {
$.ajax({
[code]....
View 3 Replies
Aug 23, 2009
How do I make a loop from 1 to 100 and make it everytime it loops display incrementing numbers to the screen?
View 1 Replies
Dec 19, 2011
i want to set a link in VB.net dynamically to a file. My url looks like that:
[Code]...
View 3 Replies
Oct 17, 2009
i use this:
Try
' Create an instance of StreamReader to read from a file.
Using sr As StreamReader = New StreamReader("musik.txt")
Dim line As String
[code]....
In the line line = sr.ReadLine I dont want the full path Maybe i have c:lalalalamin.mp3 And i just want to show min.mp3?
View 7 Replies
Aug 8, 2009
I'm trying to figure out how to get the file name of the application at run time, in case it gets renamed.Also, as a easter-egg. First post, I don't know what code to put but this is how I am so far, the {FN} is where I need the file name.
If({FN} = "easter.exe") Then
msgbox("You found a easteregg! :O")
end
View 2 Replies
Aug 14, 2010
I often use things like the crosshatch in filenames to group them together. Until recently this has not been a problem.
I am working modifing a WPF app which uses a Listbox to store images. I need the full path of the image to feed to a class to retrieve metadata.
The test image is named "# Canon-ixus.jpg".
Using Listbox.SelectedValue to return the filename I get "%23 Canon-ixus.jpg". There are not a whole lot of options to returning the name of the selected item from the Listbox.
Is there any simple way to get the name back to its original form?
View 10 Replies
Dec 8, 2010
I have a filename SBSA_UPLD_20101208 and I am interested in reading the Last date part which is 20101208. How can I do it?
View 1 Replies