Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cannot write to the INI file
Message
From
16/08/2006 20:40:11
 
 
To
16/08/2006 19:03:52
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01146174
Message ID:
01146230
Views:
22
After having tested for about an hour, here is why this wasn't working. If someone can explain that to me, it would be appreciated as this simply doesn't make any sense to me.

I have this declaration:
        Private Declare Auto Function WritePrivateProfileString Lib "kernel32" _
         (ByVal lpApplication As String, _
          ByVal lpKeyName As String, _
          ByVal lpString As String, _
          ByVal lpFileName As String) As Integer
and this method:
        ' Write a Main.ini file value
        ' expC1 File
        ' expC2 Section
        ' expC3 Key
        ' expC4 Value
        Public Function WriteIni(ByVal tcIniPath As String, _
         ByVal tcSectionName As String, ByVal tcKeyName As String, ByVal tcValue As String) As Boolean
            Dim lnResult As Integer = 0

            lnResult = WritePrivateProfileString(tcSectionName, tcKeyName, tcValue, tcIniPath)

            ' If we were unable to write into the INI file
            If lnResult = 0 Then
                Return False
            End If

            Return True
        End Function
On the Web site directory, I have Main.ini. I can call WriteIni() and replace a value in it. This works ok. But, if I go in Windows Explorer, right click Copy, right click Paste, and rename the file to Main2.ini, this wouldn't work anymore. As soon as I make a copy of Main.ini to something else by the use of Windows Explorer, I can no longer use WriteIni(). It simply cannot write anymore to the file. It seems Windows changes the codepage of that file and this confuses WritePrivateProfileString().

The only way I was able to use another INI file was to upload the file to my FTP server, rename it there and download it under the new name. As this doesn't change the codepage, I am able to use the file.

But, this doesn't seem right to me. Is there a problem in the declaration?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform