Jump to content
Xtreme .Net Talk

ADO DOT NET

Avatar/Signature
  • Posts

    162
  • Joined

  • Last visited

Everything posted by ADO DOT NET

  1. Hi, Thank you very much for your help :) So this final code still does not work on XP: Declare Auto Function PathMakeSystemFolder Lib "shlwapi.dll" Alias "PathMakeSystemFolder" (ByVal pszPath As String) As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Create Directory If Not My.Computer.FileSystem.DirectoryExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information") Then System.IO.Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information") End If 'Create File Dim FileContent As String = "[.ShellClassInfo]" + vbNewLine + "IconFile=%ProgramFiles%\Company\Product\Program.exe" + vbNewLine + "IconIndex=0" + vbNewLine + "InfoTip=Information collected using our application" If Not My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini") Then My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini", FileContent, False) End If PathMakeSystemFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information") End Sub :(
  2. Well, thanks :) This code must work now, but it's not :( Declare Auto Function PathMakeSystemFolder Lib "shlwapi.dll" Alias "PathMakeSystemFolder" (ByVal pszPath As String) As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Create Directory If Not My.Computer.FileSystem.DirectoryExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information") Then System.IO.Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information") End If PathMakeSystemFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information") 'Create File Dim FileContent As String = "[.ShellClassInfo]" + vbNewLine + "IconFile=%ProgramFiles%\Company\Product\Program.exe" + vbNewLine + "IconIndex=0" + vbNewLine + "InfoTip=Information collected using our application" If Not My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini") Then My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini", FileContent, False) End If Dim FileDetail As IO.FileInfo = My.Computer.FileSystem.GetFileInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini") FileDetail.Attributes = IO.FileAttributes.Hidden + IO.FileAttributes.System End Sub
  3. Hi PlausiblyDamp, Thank you very much for your tip. However, it won't work :( I really don't know what should I do. Even if I use Windows to Customize this folder for me, it will create the same file as me! When Windows creates it, it works! :confused: Please help me :(
  4. Hi everybody :) I wanna create a folder in My Documents, named "My Information" for example! And customize its ICON by placing a "Desktop.ini" file into that. So I wrote this code which works perfect, but I don't know why it does not show the ICON as expected :( 'Create Directory If Not My.Computer.FileSystem.DirectoryExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information") Then System.IO.Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information") End If 'Create File Dim FileContent As String = "[.ShellClassInfo]" + vbNewLine + "IconFile=%ProgramFiles%\Company\Product\Program.exe" + vbNewLine + "IconIndex=0" + vbNewLine + "InfoTip=Information collected using our application" If Not My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini") Then My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini", FileContent, False) End If Dim FileDetail As IO.FileInfo = My.Computer.FileSystem.GetFileInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini") FileDetail.Attributes = IO.FileAttributes.Hidden + IO.FileAttributes.System
  5. Hi, I have a single line of code in VB6 which I wanna convert to .NET: Here is my VB6 code: If CDbl(Right(Results, 1)) = 0 Then Rights = 500 I already have converted it and here it is: If Convert.ToDouble(Results.ToString.Substring(Results.ToString.Length - 1, 1)) = 0 Then Rights = 500 Just to make sure if I converted correctly and there is no shorter/better way specially for Right$ function, please let me know if my conversion is OK? Thank you very much.
  6. mmm, English is not my local lang, however "flank speed" is used on virtual things like email? for example is it ok if I say "email sent at flank speed"?:confused: is it also formal or informal?
  7. Hi, I want to convert this function to VB.NET: Private Function FilterFileName(ByVal FileName As String) As String FilterFileName = Empty Dim MyLoop As Integer For MyLoop = 1 To Len(FileName) If Asc(Mid$(FileName, MyLoop, 1)) >= 97 And Asc(Mid$(FileName, MyLoop, 1)) <= 122 Or _ Asc(Mid$(FileName, MyLoop, 1)) >= 65 And Asc(Mid$(FileName, MyLoop, 1)) <= 90 Or _ Asc(Mid$(FileName, MyLoop, 1)) >= 48 And Asc(Mid$(FileName, MyLoop, 1)) <= 57 Or _ Asc(Mid$(FileName, MyLoop, 1)) = 32 Or _ Asc(Mid$(FileName, MyLoop, 1)) = 45 Or _ Asc(Mid$(FileName, MyLoop, 1)) = 95 Then FilterFileName = FilterFileName & Mid$(FileName, MyLoop, 1) End If Next End Function Everything is alright, I just cannot find the new Asc() method in .NET. Each old method has a .NET version, for example InStr instead of Mid$ but where is new method for ASC()? Thanks.
  8. I have an array here: Private AttachName() As String In my code probably I will add something to my array, and possible that I don't! However, how can I finally find out if the AttachName has anything inside or not? If AttachName.Length = Nothing Then ... I get error: 'System.NullReferenceException' What should I do?!
  9. Hi, How can I check how many "/" is in a string, JUST with .net functions? Is there a straight way without looping? Thanks.
  10. Yes, this was the only thing I was thinking of! But, I don't want to download it, it may take time, the file maybe large in size, I just want to check if it exists!:confused:
  11. Hi, I am getting a URI address from user, something like: http://www.domain.com/images/logo.jpg How should I quickly validate the user entry by checking it online to see if the file exists on the remote server or not? Thanks!
  12. Hi, I want to check if my user is admin or not? IF not, give him a nice error and End my application! I only need to run this in Windows XP, Vista and Server 2003 ! I have these 2 codes: CODE 1: If My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) Then End End If CODE 2: Dim wp As New WindowsPrincipal(WindowsIdentity.GetCurrent()) If wp.IsInRole(WindowsBuiltInRole.Administrator) = False Then End End If I just wanna know which one is correct and better to use for me? What's the different between these two? Thank you.
  13. Hi, In VS.NET 2008, in project properties window, a new button added named "View UAC Settings". If I set it to: <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> 1. Then my application will run in Vista ONLY as admin mode with full privileges? 2. So I won't need to internally check in my application if user is admin and warn/close? 3. This only works for Vista? Or XP also? Thanks
  14. Pleaseee! Help me! :( That code works fine, but returns: C:\Documents and Settings\User\Local Settings\Application Data - I wanna get: C:\Documents and Settings\User\Application Data - So I changed: CSIDL_LOCAL_APPDATA to: CSIDL_APPDATA But I get error: CSIDL_APPDATA : Variable not found! Why this occurs?:(
  15. Hi, Thanks for your help. However, I am working in VB6. This will work even in Windows 98 and ME? Thanks.
  16. Hello, 1. In which Windows versions "Application Data" path is available? 2. In Windows versions that do not have this path, what should I do? Thanks :)
  17. Hi everyone:) I have a thread question! I use this code to start a thread: Dim Threads As New Thread(New ParameterizedThreadStart(AddressOf MyThread)) Threads.Start() And here is inside my thread: Private Sub MyThread(ByVal o As Object) ... End Sub I want to know how can I CLOSE the form from inside thread? Please help me as I am not very PRO in threads! For example, I know to set the TEXT in a thread I should use this: Private Delegate Sub SetAccountsTextCallback(ByVal Message As String) Private Sub SetAccountsText(ByVal Message As String) On Error Resume Next If Me.AccountsProgressBarX.InvokeRequired Then Dim d As New SetAccountsTextCallback(AddressOf SetAccountsText) Me.Invoke(d, New Object() {Message}) Else Me.AccountsProgressBarX.Text = Message End If End Sub But cannot imagine how to close the form!
  18. Hi, I need help with ListView control. I have 3 columns in my ListView, when I want to add rows with 3 columns at run time I use this: MainListViewEx.Items.Add("Column 1") But it only fills the first column of each row and then go to the next row. How can I fill all columns of a row and then move to the next row? I was not able to find it on MSDN! :(
  19. Hi, I want to download a string from a page in my site, so I use this and it works: NewString = WebClient.DownloadString("http://www.domain.com/setup.txt") Just 1 problem that if there is a connection timeout, my application hangs out. So should I use WebClient.DownloadStringAsync? If so how? I wrote this code but it doesn't work: Dim SiteURI As New Uri("http://www.domain.com/setup.txt") NewString = WebClient.DownloadStringAsync(SiteURI) Please help me :(
  20. Hi, This code was converted from VB6 to VB.NET 2005: Public Function ConvertBytesToMBString(ByVal BytesDouble As Double) As String On Error Resume Next ConvertBytesToMBString = VB6.Format(BytesDouble / 1048576, "#########0.#0 MB") End Function I don't want to use Microoft.VisualBasic.Compatibility in my application! My question is that what is 100% .NET version of this code? VB6.Format(BytesDouble / 1048576, "#########0.#0 MB") Any idea?
  21. Hi all, I am looking for the icons of US 52 States flags! I mean each state has a flag, so I need the 16x6 icon of each flag. I searched internet a lot but didn't find any free good icons, I just wanted to see if you know a good one! :D
  22. Hi, I want to extract all IP addresses using Regular Expressions: - Dim MC As MatchCollection = Regex.Matches(ReadText, "([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9])") - A valid IP address will be in format: xxx.xxx.xxx.xxx Each xxx can be from 0 to 255, so it can be from 1 to 3 characters. I think the above code should be OK. Just there is a problem that it will accept numbers like 6.2600.5.1 which is invalid. I know that to force it to accept only 1~3 char numbers I should use {1,3}, yes? But I don't know where to place the {1,3}? Please help me. Thank you.
  23. Nothing! :( I don't know what to do :( Please help meeeeee :((
  24. Dear PlausiblyDamp, thanks for taking the time to help me:) I have snapshots of the problem here. If I press debug, I will see that CantStartSingleInstanceException occurred. I can find the related page on MSDN: http://msdn2.microsoft.com/en-us/library/microsoft.visualbasic.applicationservices.cantstartsingleinstanceexception.aspx But this page does not have a sample on how to use it and I really am confused how and where to catch this exception? Also, Merry Christmas :D
×
×
  • Create New...