VS 2010 Generate Image Path From Unique Name, What To Do With Invalid Chars

Apr 15, 2010

I'm creating a radio streaming application, which plays a live stream from various radio stations in a small 'gadget' like application.

The user can add his own custom radio stations, by supplying a Name, a StreamUrl and, optionally, an Image that represents a logo or something of that radio station.The logo will be drawn on the main form when that station is selected.

I need to be able to save these custom stations, and I think it makes sense to use an XML file, which could then look something like this

<CustomStations>
<Station>
<Name>Radio 1</Name>

[code]....

Before I added the support for images, this worked fine, how to store the images. I want the user to be able to select any image from his harddrive, but I don't want to force him to keep that image in the same location afterwards. So I can't rely on the path that he selected. Instead, I want to simply load the image from the path he selected, and then save it somewhere else.

I am storing the XML file in the common application data path which I think is a good place for the images too.The problem is, how to determine a name for the images? I will always have just one image per custom radio station, so it makes sense to me to simply have one Images folder that holds all images, with a unique name.I can see two solutions:

1. Generate a random filename for every image

2. Use the Name of the radio station as the image name

For option 1, I suppose I could just create a string of 16 random characters and call that the filename. The problem of course is that there is no guarantee that I will get a unique filename. Yes, the chances of generating the same name twice randomly are very tiny, but it's still possible, and I just don't like that. How can I ensure that my random filename is unique? I suppose I could always drop the whole thing in a While loop that continues when the new filename already exists, but there must be a better way... Is there nothing in the framework that allows me to generate a unique random filename, in a directory of my choice (so not in the Temp directory...)

I like option 2 much better. The Name of a radio station is unique (there can't be two stations with the same name), so I don't have to worry about filenames conflicting. The problem with this approach is that there are no restrictions on the name. There's nothing stopping the user from naming their custom station "Radio~/aij!""_.fe" or something like that, which is obviously not a valid filename... So, I will have to do 'something' to generate a valid filename from the station name. I could simply remove all non-valid path characters from the name, but then I am no longer guaranteed a unique filename... Suppose there's two stations, one called "Radio/1" and one "Radio1", then after removing the invalid "/" character, the names will be the same and so I will generate the same image path for both....

View 8 Replies


ADVERTISEMENT

VS 2008 Writealltext Method Generate Some Unwanted Chars When Writing Txt Files?

Aug 19, 2009

I have a problem when writing some text to txt files.Here is my My.Computer.FileSystem.WriteAllText("test.txt", tekst, False)where tekst is a string variable.

When opened in some HEX editor, test.txt begins with 3 unwanted characters - ASCII values: EF BB BF. Notepad isn't showing them.

View 5 Replies

Resolved Normalize Path With Length More Than 260 Chars?

Feb 8, 2010

My issue is to combine two paths which one or both of them may contain double dots. I used Path.Combine(string, string) and the returned string is still a long path as a result of concatenating these two paths. Single or double dots are not eliminated.

So, I tried to use Path.GetFullPath(string) method with the concatenated path as the argument.PathTooLongException is thrown because this path has more than 260 characters. However, if this path is normalized, it won't exceed the maximum characters for a file path.

[Code]...

View 5 Replies

Generate A Unique ID?

May 12, 2006

I want to generate a unique ID in VB.NET that starts with ASXXXXX where XXXX represents a number. The number has to start in an orderly fashion. This ID will then be stored in a SQL Server express table.

View 8 Replies

Generate A Representative And Unique Key?

Jul 14, 2009

I am generating license key for our software. I have encrypted the input data and converted it to base64string. Now i want to generate a 12 character key from it. How to I generate a representative and unique key?

View 3 Replies

Generate A Unique ID Using Char?

Nov 24, 2009

I'm creating a program, and as part of it I'm storing a customer ID, which will be automatically generated using some form of combination of the customer's first name and surname? My thought so far has been to declare individual characters as Char and then put them together to automatically generate a customer ID? Problem being

View 7 Replies

Generate Unique Id Per User?

Mar 19, 2011

I have a webpage Default.aspx which generate the id for each new user after that the id will be subbmitted to database on button click on Default.aspx...

if onother user is also entering the same time the id will be the same ... till they press button on default.aspx

How to get rid of this issue...so that ... each user will be alloted the unique id ..

View 4 Replies

Generate Unique Ref No In Form?

Sep 20, 2011

I have no idea about this. Actually i have create one form like personnel requisition form.hen user open the form, ref no will appear at the top of the form. ref no is used to search any personnel requisition later.

View 5 Replies

Generate A Unique Number From DB Tables

Oct 12, 2010

I once posted a question on generating a policy number by table ID and user selctions from comboboxes. [URL]FYI . I am doing my project in vb, that why i posted it here. I managed to do that when i choose a region and product from two different comboboxes i generate a number but now my problem is that whenever i click on the comboboxes a policy number is generated before i save the record, so if my previous nummber was 72100002 whenever i click on the product combobox i generate a number e.g if i click on it five times by the time i save the number would be 72100007. I am using a stored procedure for this. Is there another way of doing this or i might end up with my first record as 72100001 and my second record 72100006.

[Code]...

View 2 Replies

How To Generate Unique Random Number

Aug 2, 2009

I have an application that is made for a game that you have to draw cards for. So what I have done is created a random number generator that generates a random number and then using case statements that number is associated with a picture of the card, which is displayed in a picture box. This part works fine. Each time I draw a card it is not reshuffled so I need to store the random number generated and then if that number is generated again ignore it an generate a new number.

Now to complicate matters even further when a certain card is drawn the entire deck is reshuffled and everything starts over again. Here is what I tried... I tried using arrays to store the numbers but I cannot seem to get it to search the array for the number or store the number properly within the array. The array has to be dynamic since the game is expandable and I will be adding more cards to the game in the future.

View 18 Replies

Program To Generate Random Number But They Are Not Unique

Apr 1, 2007

I am working on a Bingo game and I am stuck. I got the program to generate random number but they are not unique. I dont know how to fix this. I have researched online and nothing this is my last resource. I am using Visual Basics 2005 Express Edition. [code]

View 9 Replies

.net - Generate All Unique Combinations Of Elements Of A IEnumerable(Of T)?

May 12, 2011

This question is virtually the same as this SO post, only I'm looking for a VB.NET (.NET 4) solution. I've spun my wheels long enough trying to come up with a generic solution to solving this "power set" problem.

Dim choices As IEnumerable(Of String) = {"Coffee", "Tea", "Milk", "Cookies"}
Dim choiceSets = choices.CombineAll()

I'm looking for choiceSets to be an IEnumerable(Of IEnumerable(Of T)) so that I can do something like:

For each choiceSet in choiceSets
Console.WriteLine(String.Join(", ", choiceSet))
Next

[code]...

As you can see, this is every non-repeating combination from the source IEnumerable(Of T) (which could have 1 to many items in it - this example only had 4), it operates based on the order of the items in the source IEnumerable(Of T), and each item in the list is >= the previous item in terms of number of items in the inner IEnumerable(Of T).

For what it's worth, this is not homework; though it sure does feel like it. EDIT: Updated the example so it does not look like the result is alphabetically sorted, to stress that the source IEnumerable(Of T)'s existing order is used and added a 4th choice to clarify the sorting requirement within each set.

View 5 Replies

C# - Generate Unique Random Prominently Color?

Apr 15, 2011

I am trying to generate Unique and prominently random colors in c# or vb.net. I am using below code now. But this code generating color almost same color, not big change.How can unique kind of colors?

[code]...

View 3 Replies

Generate Unique Receipt Number In Certain Range

Dec 21, 2009

How would I go about generating a unique receipt number in the following range:
GA00000-GZ99999? I am not allowed to use the 'I' and 'O' letters so GI00000-GI99999 & GO00000-GO99999 would be excluded. Ideally, I'd like to create this in T-SQL but can also do it in VB.Net. This number will be stored in SQL and I can access it prior to generating the next one. They do not have to be sequential.

View 4 Replies

How To Generate Unique ID Based On Combobox Selection

Apr 9, 2009

how to generate unique ID based on combobox selection?

View 5 Replies

VS 2010 : Get Path Of Background Image?

Jun 4, 2010

How would I get the file path of my form's background image? I tried me.backgroundimage.tostring but it always came back as something like system.forms.bitmap or something.

View 2 Replies

Auto-generate Unique Number On The Form When An Application Starts Up?

Jul 19, 2007

Is there a way to auto generate unique number on the form when an application starts up and it should incremente in the dataadapter and database too. How can i set it up?

View 10 Replies

Generate A Unique Number From DB Table ID, Time And Selected Product?

Sep 21, 2010

I'm developing a policy administration system and I need to generate a unique policy in this formart

RP000000/HH

Where R is the Region i select from a Combobox, P is the product the client chooses and the auto generated six digit number and HH is the hour when the record was entered in the system. I want the auto generated number to be the ID in my ClientDetails table in my DB.Here is my code of what I have done so far.They want to be able to tell the region and the product by just looking at the policy number.

Private Function PolicyNumber(ByVal intRegion As Int16, ByVal intProductCover As Int16) As String
PolicyNumber = intRegion.ToString & intProductCover.ToString & "000000" & "/" & Hour(Now).ToString
End Function

[code]....

View 2 Replies

Path Format Invalid

Jan 31, 2012

I have shared a folder from another server to th eone am running the executable file. [Code]. I receive the error at the highlighted text. Thats the other server where the shared folder can be seen in the server am running the executable file. why I receive that error? The given path's format is not supported.

View 12 Replies

.net - Regex Replacing Non-words Chars In Strings, Ignoring Specific Chars?

Oct 8, 2011

In VB.net I've got the following line that removes all non-alphanumeric chars from a string:

return Regex.Replace(build, "[W]", "")

I now need to extend this to remove non-alphanumeric chars that aren't [] or _. I've changed the line to:

return Regex.Replace(build, "[W[]_]", "")

However I'm pretty sure that this says

replace non-word or [ or ] or _

how do I negate the tests for the [] and _ chars so that it says

replace non-word and not [ and not ] and not _

Some examples:

"[Foo Bar_123456]" => "[FooBar_123456]"
"[Foo Bar_123-456*]" => "[FooBar_123456]"

View 2 Replies

VS 2010 Image.fromfile Query - Set Images To A Text Box - Use A Full File Path?

May 17, 2011

I have been using the image.fromfile to set images to a text box but I always have to use a full file path. Like here;

[Code]...

View 3 Replies

.net - Cast A List Object Of Chars In An Array Of Chars?

Nov 20, 2010

How to convert or make a cast of a List object typized as a container of chars like

Dim mylist As List(Of Char) = New List(Of Char)(New Char() {"1"c, "2"c})

in a simple array of chars as

Dim mychars() As Char

without make a loop for...

View 1 Replies

VS 2008 .DBF Connection String - Invalid File Path?

Sep 21, 2009

Dim dbconn As OleDbConnection
Dim DBCommand As OleDbDataAdapter
Dim DS As New DataSet
dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:COLORsitedataCUFORHDR.dbf;Extended Properties=dBASE IV;")

[Code]...

I prefer SQL server but im afraid in this app I have no choice. I think the .DBF file is v III dBase according to a thrid party .dbf viewer. The code explodes on the DBCommand.Fill(DS) line, telling me I have provided and invalid file path. The path is good to go.

Should I be using a driver with a different provider? When I remove the Extended Properties parameter I get an error unrecognizable database format - hinting in this case the path is correct.

View 3 Replies

Return An Error Message When The User Selects An Invalid File Path?

Apr 17, 2012

I'm using Microsoft Visual Basic 2008 Express Edition. I have a Folder Dialog Browser added in my form and I call it when the user presses a button. The folder path string is stored in a string variable and displayed as text in a text box. (maybe I should use a combo box)

My question is: If the user inputs by hand a non existent path, how do I return an error message, stop the file creation into the invalid path, and return to my main form?

View 1 Replies

VS 2005 Tree View Full Path Function Gives Invalid String

Oct 3, 2009

I thought I was done with the tree view control until i realised that my tree view control was behaving differently when it came to sub nodes . I have attached my treeview pic and also a sample tree view.

(-)D:
|_config.msi
|_netfile.sys

[Code]....

Since I clicked on subfolder1 i was expecting the msgbox to display D:Folder1Subfolder1 but unfortunately the msg box doesnto even have the name of the node i clicked on but when i use selectednode.text I get the correct node text. Anyways why isnt my full path working. I then tried manually designing the entire scenario using tree node editor and the code which i mentioned above works. But whenever i populate the trr programatically the above problem starts.

View 4 Replies

Generate A Virtual Disk / Path?

Mar 26, 2009

Is there some way to generate a virtual disk/path?My application needs to generate a lot of temporary small files, edit them, write to disk, execude old executables in Fortran, and read the text files outputs.I cannot choose to avoid the fortran, because is out of my power to decide it.all that I/O is really expensive, because disk access is slow. But all the files involved are really small (including the executable), so they may fit on a few megabytes of RAM, and I have gigabytes of RAM available (RAM is really cheap today).Worse, I cannot parallelize, because it forces me to multiply I/O operations (I need to create, edit, and delete lots of small files).The perfect solution would be to have a small virtual disk in memory.I cannot use a virtual PC software, because users would have a hard time installing it (they have problem using windows explorer even to do simple tasks).

View 4 Replies

Invalid Path To Database Error Message After Deploying Project Created In Program2010

Jul 6, 2011

Is there any literature which guides a user through the steps of deploying a vb project created with VS 2010 Professional and incorporating SQL 2008RE Database?

I have a VB project which incorporates 2 databases - 1 Access Db and 1 SQL Db. The project compiles and runs beautifully. However, after adding the databases in the project as existing items and deploying, the project opens/runs, but when I try to login the application I keep getting an error message telling me that the path to the .mdb (Access) database is not a valid path. I don't have a clue what else to do.

View 19 Replies

Generate 6 Unique Random Numbers - Sometimes Get Duplicate Numbers ?

Oct 6, 2011

The program must generate 6 unique random numbers but when I click display numbers sometimes it gives me 6 unique numbers and sometimes I get duplicate numbers. I will add the code I have so far.

Public Class frmMain

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

[CODE]...

View 9 Replies

PictureBox - Image: Select The Path To A Local Folder That Is Within The Application And Get An Image From It?

Sep 15, 2010

I have a Picturebox and a two Buttons on my Form. On click of one of the buttons I want to change the image in the picture box at runtime.

This works fine when I give the location of the image (the full path ) on my computer - but then of course it will not work if I use the solution on a different computer .

So I have made a folder named "Pics" inside my application and added two images into it.

How do I get to this local folder in the following code?

Picturebox1.image = system.drawing.image.fromfile (??? )
instead of the usual,
Picturebox1.image = system.drawing.image.fromfile ("C:UsersMyName My PicturesMyPicture.jpg" )

View 11 Replies

VS 2010 Reading Chars From A String?

Nov 11, 2011

still pretty new to programming in general, but I have most of the basics figured out.I stumbled across this problem today, though. I wanted to try making a simple encoder/decoder. However, I am having trouble getting characters from a string.

I have a list(of char) to separate the individual letters in the message (letterList), and textToConvert is the text that the user types in to be encoded. Here's the section of code my problem exists in:

For i = 0 To textToConvert.Length - 1
letterList(i) = textToConvert.Chars(i)
Next i

Upon running my program, I get an out of range exception for the middle line above. Am I doing something wrong?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved