VS 2008 Scan A Long String And Return Any Values That Occur Between The Tags <FileName> And </FileName>?
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:
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)
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();
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
I am trying to make a filename something like this:
dim Test as string = "name_" + now.toshortdatestring() + ".pdf"
The datestring is like MM/DD/YYYY, which is a particularly bad filename (who want slashes in their file names??)Is there a way to format the date string differently (ie MM-DD-YYYY)?What I was trying to do is tag the file with a date so I could tell when the last time that file was generated, and also keep multiple copies around for archive purposes. Maybe there is a better way and then I dont even need this differently formatted string?
I have a userform in 2008 vb express edition. A part number is created from user input via a concat string. I want to then check if a certain portion of the part number exists in the existing file names in a directory. Below is a more detailed explanation.[code]...
I have a piece of code to debug. Because of unknown bugs it creates a dummy filename. I want to track all the pieces of code who fires that creates the dummy filename, so I can change the dummy file creation to a thrown exception. Since I the dummy filename is stored on a string, I plan to modify that string to contain an invalid NTFS filename, maybe containing invalid chars. Is there a reason to prefer some invalid chars over others? There are some predefined invalid NTFS filename destined to this purpose? (I may think of AUX , COM1 , LPT1 or PRN , but those names run the risk of start sending data to a port instead of throwing an exception).
Public Sub saveExcelFile(ByVal FileName As String)Dim Excel As Object
[Code]...
that is my code. everytime i open the saved file, it says that it has a different file type and asks me if i want to continue opening it and i click yes. the data inside the excel file is only the word "Success"
I have a quite simple application that is having some random locks up. It's just a few text fields that the user fill it up, 3 sets of Radio buttons, one of them with flags to chose the language and click the PDF button. The application uses iTextsharp to load a PDf template, insert the text into it, depending on the language loads some extra text from a .xml file, and depending on the radio button removes the images from the PDF, closes the pdfstamper and uses [Code] to open the file with whatever PDF application the user have installed and closes itself.
Sounds simple, but after the application is installed in the machine (never in debugging mode) it randomly locks up the application. I tried re-publish the application commenting out the Start(filename) line and the thing stopped locking. And I double checked it, re-publish with the line again and it locked after just a few attempts. [Code]
I got an easy one this time How can I get a file knowing the path and the name of it, but not knowing the extension which I need to get. You can see at the moment I use this silly code which finds and opens some main filetypes for me, but if I could get hold of the file extension just by using the filename and the path I could open any document or image...
I am trying to get the filename from the OledbConnectionStringBuilder Property. I have the following
Dim DataString As New OleDb.OleDbConnectionStringBuilder(My.Settings.RestelConnectionString) Dim DBFilename As String = DataString.FileName DataString returns C:Documents and SettingsMartinMy DocumentsVisual Studio
I'm creating an MP3 player. I have a listbox and OpenFileDialog control. I want to load an mp3 file in the listbox but I only want the file name to show rather than the whole file path, how can this be done?
I have an application that has a list of string that needs to be search in a database table field to select rows with the same name and retrive the values of one particular fields that contains the file name with extention for that string. With this new generated text file, I pass the filename with the extension and search the folders that are listed in a txt file. All of this works fine.
Now I need a more simple version of this application, without using the database to get the filename with extension. Instead, read the text file with input strings, search in the folders listed in another text file(to know the location of the folders to search for the string). If any file that matches with the string in the text file, I need to copy those files to another folder.
is there any way to attach a sql mdf by filename but actually make the database name something else?
the problem i'm having is that my connection string attaches the database just fine, but it gives the database a name of it's full path on the hard drive when i pull it up in SSMSE. ie. "c:program filesmy programmy database.mdf" is shown as the name when i do a sqlcmd and issue a select name from sys.databases
the snag is being hit due to the fact that i'm trying to do a "bcp in" and because a: there are spaces in the database name, and b: there's the .mdf extension also added to the database name that when i run my bcp in command it errors out, even if i use the -q option of bcp.
if i start SSMSE and right click the database and rename it, bcp works great - so my question is, how do i correctly format my connection string to attach to c:program filesmy programmy database.mdf, yet have it attach the database as "mydatabase" for use in bcp statements?
i've been to connectionstrings.com and they only cover the standard connection strings
in summary - i want to attach an mdf file programmatically and specify the name that ssmse see's it as....
This code works fine for returning the short name of path/file in XP x32, but in Windows 7 x64 it doesn't return anything.How do I get the short path/filename with vb.net 2008 in Windows 7 x64?
I'm stuck at making an vacationplanner. For example: an employee can request a day off which request is send to an access database. After which the request has to be approved (or declined) by a supervisor. The supervisor logs in and goes to a overview form to see outstanding and approved request. I use a Datagridview to display the name of the employees at the Y-axis and the corresponding days in the selected month in the X-axis. Then I loop through the access database to fill the specific cells with an grey image on specific days for part-time employees.
After this I loop through a seperate accessdatabase to retrieve the outstanding and approved requests and fill the corresponding cells with an image. Example: yellow image for outstanding and green for approved requests. dgvBezetting.Item(dag, rij).Value = Image.FromFile(Application.StartupPath() & "/uren/grijs.jpg") Now I get to the part where I'm kind of stuck.
In the mentioned datagridview the supervisor can see the already approved requests. But, when an employee suddenly changed or canceled the already approved day off, the supervisor must be able to delete the request. I can find out with hitTest on which cell the supervisor has clicked and from there check the database for request entries, but this will consume a lot of database transaction when the supervisor keeps clicking on cells witch no data in it.
What I preferably want..... I actually want to check if the clicked cell contains an image or not and from there on continue with an connetion to the database or not. But, I can't figure out how to retrieve the imagename or if there is an image used or not... I only get the result 'System.Drawing.Image', 'System.Drawing.Bitmap' or 'Image', nothing referencing to the imagefilename..
I got a string that is going to be used as a filename. Is there any solution to find and replace non-valid chars with "" so I can use the string as a filename without any problem?
I am wondering if there is a way to extract a file's title name from the FileName property.VB6's Common Dialong had "FileTitle". That seems to be gone. I have a small window app that does not have the room to display the full path as part of the window title.
I am looking for an advise on how to find out the extension of the file only knowing the name and the location of it. I tried getextension method and some other but they don't seem to do anything to me.
E.G.: Dim FileFullPath As String = "\SERVERPublicCRM_LibraryOrderMGMLetters" & datagridLetters.CurrentRow.Cells.Item(0).Value.ToString() & ".pdf"
I would like to use a SaveFileDialog to retrieve a path and filename.
Like for example: You choose a saving location and filename in the SaveFileDialog, and then when you press save the path and filename will be put in to a string as such: C:Folderfilename.txt
I am using a Balloon tooltip to show the user which characters are invalid as a filename. I use the IO.Path.GetInvalidFileNameChars array and convert each character to a string, before appending it to a "Invalid filename characters:" string. vb.net
If IO.Path.GetInvalidFileNameChars.Contains(e.KeyChar) Then e.Handled = True Dim str As String = "The following characters are invalid filename characters:" & nl Dim invalidChars As New List(Of String) For Each c As Char In IO.Path.GetInvalidFileNameChars [Code] .....
The result is not pretty: How do I get rid of the 'non-visual' characters (they are probably newlines, backspaces, null chars, etc) so they don't clutter up the list?
in my program, i use that code for getting the file path of a process, once it gets the path, it is put into a list view which has details like the task manager. the code works fine the first time, but with a little bug that is, when it reaches the vhost of my program. For some reason, it just copies the file path of my program even though the process has changed. After the code has gone through, i want it to refresh the list so as doing the same as when loaded...so I let it refresh and once again it copies the path of the vhost, but this time it has basically taken over every process' location. So in turn, I only get returned my programs location, for something like the task managers location, where it would be like "C:Windowssystem32skmgr.exe"
Here's the
VB Private Sub frmmain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim Process As New Process() Dim Count As Integer = 0
[code]....
The refresh code is frmmain_Load(Nothing, Nothing) just to make things easy for me right now, while i get that part of the program going. To me it seems to be working fine, but why it does that what it does, im not sure. as you can see, the process changes. and Ive even checked it through run time, and each and every time, the process.processname changes.
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
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?