Jump to content
Xtreme .Net Talk

Worf

Members
  • Posts

    17
  • Joined

  • Last visited

Everything posted by Worf

  1. Hi. I have tried to make a small database using arraylist to store the information in text files and doing ok. The only problem i am having is Catagories and Sub-Catagories. Below is the code i am using, it's still a bit messy at the moment with trying out different methods. I would be greatful with help with this code if i am doing it wrong. Below is the main menu. view plaincopy to clipboardprint? Public Class Menu Private Sub Menu_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Get user name Username = System.Environment.UserName End Sub Private Sub ImportFPI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImportFPI.Click ' If FPI selected then load Catagory with FPI and show the import form to import .FPI files Catagory = "FPI" ImpFpi.Show() End Sub ' View the Database Private Sub ViewFPI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewFPI.Click If FPIEmpty = Nothing Then MsgBox(Username + " Database empty, nothing to display.") Return Else ViewFPIScript.Show() End If End Sub ' Show FPI form to import .FPI text files. Private Sub FPIImport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FPIImport.Click Catagory = "FPI" ImpFpi.Show() End Sub ' Show .FPE form to import .FPE files. Private Sub FPEImport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FPEImport.Click Catagory = "FPE" End Sub ' Sub-Catagories that the FPE\FPI files will be stored under. Private Sub Enemies_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Enemies.Click SubCat = "Enemies" End Sub Private Sub Electronics_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Electronics.Click SubCat = "Electronics" End Sub Private Sub Items_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Items.Click SubCat = "Items" End Sub Private Sub Objects_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Objects.Click SubCat = "Objects" End Sub Private Sub Weapons_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Weapons.Click SubCat = "Weapons" End Sub Private Sub Water_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Water.Click SubCat = "Water" End Sub End Class This code imports .FPI text files and stores the information. Imports System Public Class ImpFpi Private Sub Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Browse.Click With openfiledlg '.InitialDirectory = "C:\" .Filter = "FPI Files (*.fpi)/*.fpi|" .CheckFileExists = True If openfiledlg.ShowDialog = Windows.Forms.DialogResult.OK Then TxtFile = openfiledlg.SafeFileName If Not System.IO.Path.GetExtension(TxtFile) = ".fpi" Then MessageBox.Show(Username + " please select an FPI file") TxtFile = "...." Else Dim ii As Integer = openfiledlg.FileName.LastIndexOf("\"c) TxtPath = openfiledlg.FileName.Substring(0, ii) End If End If End With If (Not TxtPath Is Nothing AndAlso String.IsNullOrEmpty(TxtFile)) Then MsgBox(Username + " No .fpi file selected.") Return Else TempPath = TxtPath + "\" + TxtFile Dim s As String = TempPath Dim txt As String = IO.File.ReadAllText(s) ViewFPI.Text = txt FPIFName.Text = TxtFile FPIPath.Text = TempPath End If End Sub Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click Close() End Sub Private Sub AddFPI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddFPI.Click If (Not TempPath Is Nothing AndAlso String.IsNullOrEmpty(TxtFile)) Then MsgBox(Username + " No .fpi file selected.") Return Else Try Dim s As String = TempPath Dim txt As String = IO.File.ReadAllText(s) FPITxtName.Add(TxtFile) ' Add .FPI file name to list ScriptDesc.Add(DescriptionInput.Text) ' Add description about the .FPI text file to list. Usage.Add(UsageInput.Text) ' Add Usage of the .FPI text file to list FPIItemList.Add(txt) ' Add the .FPI text file file to list. FPIEmpty = 1 ' Set to one if the FPI database is not empty. TxtFile = Nothing DescriptionInput.Text = Nothing UsageInput.Text = Nothing txt = "" Catch ex As Exception End Try End If End Sub End Class This code allows you to view the FPI text files stored. Public Class ViewFPIScript Private Sub ViewScript_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Add each FPI file name to the listbox. For Each s As String In FPITxtName ' Dim i As New items(s) ListBox1.Items.Add(s) Next End Sub Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click Close() End Sub ' Display FPI scripts that the user selects from the listbox.Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged For j As Integer = 0 To ListBox1.Items.Count - 1 If ListBox1.SelectedIndex = j Then Label2.Text = FPITxtName.Item(j) ScriptDescr.Text = Convert.ToString(ScriptDesc.Item(j), CultureInfo.CurrentCulture) UsageInput.Text = Convert.ToString(Usage.Item(j), CultureInfo.CurrentCulture) FPIScript.Text = Convert.ToString(FPIItemList.Item(j), CultureInfo.CurrentCulture) End If Next End Sub End Class What i can't figure out is how to apply the Catagory and Sub-Catagory for each FPI script so that when the user selects a sub-catagory, any FPI text files stored under it is displayed. So, if the user selected Catagory - FPI and Sub-Catagory - Enemies, the FPI text file is stored under this Catagory and Sub-Catagory. As you can see in the menu code there is also an 'FPE' and other Subcatagory. Thank you for your help. Worf.
  2. Hi. I don't know anything about Databases and i want to create a database to store the contents of text files and other information. What it will hold: Contents of text files. Description of the text files The usage of the text files. Name of the text files. So, i have a text file, the application reads the contents of the text file and stores that information in the database. The user will be able to type the description of what the text file is and also the usage and store this with the text file. There will also be Catagories and Sub-Catagories which the text files will be stored under. Example: Catagory: FPI Sub-Catagory: Enemies. So, if the user selects FPI & Sub-Catagory Enemies, then the text file will be stored under this. I have managed to use ArrayList to store the information but but not sure how to do it with Catagories and Sub-Catagories. Many thanks for your help. Regards Worf
  3. Well the problem is that this routine is not seeing those files and showing the error message.
  4. Hi I am trying to check if multible files exists and i can not seem to figure out how to get it to work. Below is what i use. If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then FileContents.Text = FolderBrowserDialog1.SelectedPath.ToString If (Not (IO.File.Exists(IO.Path.Combine(FolderBrowserDialog1.SelectedPath, "WIN51IP.SP3"))) _ Or (Not (IO.File.Exists(IO.Path.Combine(FolderBrowserDialog1.SelectedPath, "WIN51IC.SP3"))))) Then MESSAG = DataDLL.MSGS(1) Message.Show() FileContents.Text = "" Exit Sub Many Thanks for any help Worf
  5. Hi all Ok, i've been trying to work this out for hours but without any luck. The code below saves the contents of listbox2 to a folder, removes unwanted characters and then shortens the file name length down to 8 characters. Now, what im trying to do is to put the filenames from listbox2 into a string 'JPGFILENAMES' which will hold the filenames before being modified (ie. Vista Areo.jpg) Next, i need to have the modified filenames put into another string 'JPG' (ie VistaAre.jpg) Now, when all the filenames have been put into each string they would look like this: JPGFILENAMES(1)="Vista Areo.jpg" JPG(1)="VistaAre.jpg" ect.. Or it might be easier to write them to a text file so they would look like: "Vista Areo.jpg",VistaAre.jpg ect.. That way i could just read the text file and then write the contents to the target text file when ready. Try ' Copy files from Listbox2 to a Folder. For Each i As Item In ListBox2.Items My.Computer.FileSystem.CopyFile(i.Name, Application.StartupPath _ & DataDLL.PAPERTMP + i.Shortname) ' Remove Unwanted Characters Dim fileInfo As FileInfo For Each fileInfo In New DirectoryInfo(Application.StartupPath & DataDLL.PAPERTMP).GetFiles() Dim newFileName As String = fileInfo.Name newFileName = newFileName.Replace("_", String.Empty) newFileName = newFileName.Replace(" ", String.Empty) newFileName = newFileName.Replace("-", String.Empty) newFileName = newFileName.Replace(".jpg", String.Empty) IO.File.Move(fileInfo.FullName, fileInfo.DirectoryName + "\" + newFileName) Next ' Check Length of Filename And Shorten If Greater Than 8 Dim fileInfo2 As FileInfo For Each fileInfo2 In New DirectoryInfo(Application.StartupPath & DataDLL.PAPERTMP).GetFiles() Dim newFileName As String = fileInfo2.Name If newFileName.Length > 8 Then IO.File.Move(fileInfo2.FullName, fileInfo2.DirectoryName + "\" + newFileName.Substring(0, 8) & ".jpg") Else IO.File.Move(fileInfo2.FullName, fileInfo2.DirectoryName + "\" + newFileName & ".jpg") End If Next Catch ex As Exception MsgBox(ex.Message) Exit Sub End Try End Select Regards Worf
  6. It ok, got it working now. Many Thanks Worf
  7. Doesn't work :( Not removing characters
  8. Hi JumpyNET Thank you for your reply. This looks like just what i need, if this works i can delete the routine that removes the extention as this routine will make things alot easier for me. Many Thanks Worf
  9. Hi again. I have another problem that i need to solve to get my program to work correctly. I need a routine or a couple of lines that will remove the following characters from filenames. These are Spaces, "." and "_" the one a found does not seem to work. :( Many Thanks for you help Worf
  10. Hi PlausiblyDamp. Thank you for you reply. The reason i need to truncate the file names to eight characters is that the TXTSETUP.SIF only allows filenames of eight chars. I am writting a program that will allow you to customize Windows XP by integrating Wallpapers, Sound Schemes, Visual Styles, Registry entries ect directly into the Windows Source because at the moment you need to use $OEM$ folder to do this. I do have another problem but i will put up another post for that. Regards Worf
  11. Hi. I have found that to get part of my program to do what i need it to do with causing proplems is to remove the file extention, do what needs to be done with the files and then put the file extention back. Now my program checks if the files are more than eight characters long, if so then reduce them down do only eight characters. Now the problem i have is that some times i get (Name..jpg or Name.jp.jpg), so i need to remove the extentions then replace the extentions after they have been shortend. How would this be done? Many Thanks Worf
  12. Hi. How do you rename files to a number a charaters? If i had a file called 'Purple flower.jpg' and i wanted to rename it to 'purplef.jpg'. How do i rename it to 'purplef.jpg' Many Thanks Worf
  13. Thank you for your relply. Will try it.
  14. Hi. For some reason i am getting 'Type 'Items' not defined' in bold and i am not sure why. Anyone here can help? For Each i As Items In ListBoxControl2.Items My.Computer.FileSystem.CopyFilei.name, "C:\SFE\Temp\wallpaper\" + i.shortname) Next Many Thanks Worf
  15. [PLAIN]Re: Listbox help. [sOLVED][/PLAIN] Thank you for the Snippet, it works great :D now i can get on with my application. Once again thank you.
  16. Hi DPrometheus Thank you for your reply. I would be very greatful if you could take a look at it for me, i have been on this for just over a week now and just want to get this working so that i can get on with the next part of my application. Many Thanks Worf
  17. Hi. I am a newbie when it comes to programming and what i have done so far with my application is through sample codes, tutorials and with the help of fellow programers. I am trying to pass data and file paths from one listbox1 to listbox2, now i can pass data from listbox1 to listbox2 but i am having problems with the paths to the files listed in the listbox's. The paths to the files are not shown in the listboxs, only there filenames. My program will search a selected drive or folder for .wav files and list any found in listbox1 without there paths, (only there file names), now i have an add button so that the user can select an item in listbox1 and add it to listbox2. Now what i need to be able to do is to save the .wav files added to listbox2 to a new folder. Now what i have tried so far is to add another two listbox's called listbox3 and listbox4 which are both hidden from the user. Listbox3 holds the paths to all the .wav files found for listbox1 and listbox4 will hold the paths to the .wav files added to listbox2. Listbox3 adds the paths to listbox4 when items are added to listbox2 from listbox1. The files added to listbox2 and the paths to listbox4 are different and i can't seem to get the correct paths added to listbox4 for the items added to listox2. Below is the code that i have been trying to use. Search routine: Public Sub FileTypeFinder(ByVal dir As String, ByVal fileExt As String) Try ' Display all files in a directory that match file type For Each fname As String In IO.Directory.GetFiles(dir) If fname.EndsWith(fileExt) Then ListBoxControl1.Items.Add(My.Computer.FileSystem.GetName(fname)) listBoxControl3.Items.Add(fname) End If Next ' A recursive call for all the subdirectories in this directory. For Each subdir As String In IO.Directory.GetDirectories(dir) FileTypeFinder(subdir, fileExt) Next Catch ioex As System.UnauthorizedAccessException Catch ex As Exception MessageBox.Show(ex.Message.ToString) End Try End Sub Add Routine: Add selected items from listbox1 to listbox2 Public Sub Add_ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add_ButtonX1.Click Select Case ListBoxControl1.Items.Count Case 0 MsgBox("There is nothing to add. Please browse for wav files.") Return End Select Try ' Add the paths to the wav files from listbox3 to listbox4 ListBoxControl4.Items.Add(ListBoxControl3.SelectedItem) ' Remove the selected items path from listbox3 ListBoxControl3.Items.Remove(ListBoxControl3.SelectedItem) ' Add the selected items from listbox1 to listbox2 ListBoxControl2.Items.Add(ListBoxControl1.SelectedItem) ' Remove the selected item from listbox1 ListBoxControl1.Items.Remove(ListBoxControl1.SelectedItem) ' Save the .wav items in listbox2 using the paths in listbox4 For list2 As Integer = 0 To Me.ListBoxControl2.Items.Count - 1 System.IO.File.Copy(ListBoxControl4.SelectedItems(list2), "C:\SFE\Temp\Sounds\" + (My.Computer.FileSystem.GetName(ListBoxControl4.Items(list2)))) Next Catch ex As Exception MsgBox(ex.Message) End Try End Sub have tried different ways without any luck. Many Thanks to those who can help. Worf
×
×
  • Create New...