I am currently developing a windows application. I have a form that saves data to an ini file.
I am currently having a trouble in writing and reading ini file.
First, if the form loaded, it will read the ini file with corresponding section. it works well. But when I save / write data (one of it's key is a path (filename of the image))to ini file, changes does not reflect. When I closes the form and load it again, the data will be read as what i have saved though the changes doesn't reflect in ini file.
But, if I'm going to save the data and the path (file name of the image) is not included, changes reflects to the ini file.
I don't understand why is it happening.
I really need help here.
Below are my codes.
Save data to ini: -
private void Save()
-
{
-
try
-
{
-
IniFile.WritePrivateProfileString("MERCHANTINFO", "IMAGEPATH", imageFileName, ".\\MPC.ini");
-
IniFile.WritePrivateProfileString("MERCHANTINFO", "MERCHANTNAME", txtName.Text, ".\\MPC.ini");
-
IniFile.WritePrivateProfileString("MERCHANTINFO", "MERCHANTCODE", txtMerchantCode.Text, ".\\MPC.ini");
-
IniFile.WritePrivateProfileString("MERCHANTINFO", "SHOPID", txtShopID.Text, ".\\MPC.ini");
-
IniFile.WritePrivateProfileString("MERCHANTINFO", "TERMINALID", txtTerminalID.Text, ".\\MPC.ini");
-
IniFile.WritePrivateProfileString("MERCHANTINFO", "TEL", txtTel.Text, ".\\MPC.ini");
-
IniFile.WritePrivateProfileString("MERCHANTINFO", "FAX", txtFax.Text, ".\\MPC.ini");
-
IniFile.WritePrivateProfileString("MERCHANTINFO", "ADDRESS", txtAddress.Text, ".\\MPC.ini");
-
IniFile.WritePrivateProfileString("MERCHANTINFO", "WEBSITE", txtWebsite.Text, ".\\MPC.ini");
-
-
Common.FuncShowInfoMsg("Merchant informations succesfully saved.", "Save Successful");
-
-
btnSave.Enabled = false;
-
btnCancel.Text = "Close";
-
btnCancel.Focus();
-
-
}
-
catch (Exception ex)
-
{
-
Common.FuncShowErrorMsg("Unable to save Merchant Info.", ex.Message, "Failed");
-
}
-
}
Reading ini file: -
Common.sbName = new StringBuilder(1024);
-
Common.sbShopID = new StringBuilder(1024);
-
Common.sbTel = new StringBuilder(1024);
-
Common.sbTermID = new StringBuilder(1024);
-
Common.sbWebsite = new StringBuilder(1024);
-
Common.sbImageFileName = new StringBuilder(1024);
-
Common.sbFax = new StringBuilder(1024);
-
Common.sbAddress = new StringBuilder(1024);
-
Common.sbCode = new StringBuilder(1024);
-
-
IniFile.GetPrivateProfileString("MERCHANTINFO", "MERCHANTNAME", "", Common.sbName, 1024, ".\\MPC.ini");
-
-
-
IniFile.GetPrivateProfileString("MERCHANTINFO", "MERCHANTCODE", "", Common.sbCode, 1024, ".\\MPC.ini");
-
-
-
IniFile.GetPrivateProfileString("MERCHANTINFO", "SHOPID", "", Common.sbShopID, 1024, ".\\MPC.ini");
-
-
-
IniFile.GetPrivateProfileString("MERCHANTINFO", "TERMINALID", "", Common.sbTermID, 1024, ".\\MPC.ini");
-
-
-
IniFile.GetPrivateProfileString("MERCHANTINFO", "TEL", "", Common.sbTel, 1024, ".\\MPC.ini");
-
-
-
IniFile.GetPrivateProfileString("MERCHANTINFO", "FAX", "", Common.sbFax, 1024, ".\\MPC.ini");
-
-
-
IniFile.GetPrivateProfileString("MERCHANTINFO", "ADDRESS", "", Common.sbAddress, 1024, ".\\MPC.ini");
-
-
-
IniFile.GetPrivateProfileString("MERCHANTINFO", "WEBSITE", "", Common.sbWebsite, 1024, ".\\MPC.ini");
-
-
-
IniFile.GetPrivateProfileString("MERCHANTINFO", "IMAGEPATH", "", Common.sbImageFileName, 1024, ".\\MPC.ini");
-
0 1246 Sign in to post your reply or Sign up for a free account.
Similar topics
by: matt |
last post by:
I have compiled some code, some written by me, some compiled from
various sources online, and basically i've got a very simple flat file
photo gallery. An upload form, to upload the photos and give...
|
by: Dave Smithz |
last post by:
Hi There,
I have a PHP script that sends an email with attachment and works great when
provided the path to the file to send.
However this file needs to be on the same server as the script.
...
|
by: chris |
last post by:
I'm writing a small app to help me learn more about cryptography. All
it does is encrypt all of the files in directory A, and put the
encrypted versions of the files in directory B. It then...
|
by: simon place |
last post by:
is the code below meant to produce rubbish?, i had expected an exception.
f=file('readme.txt','w')
f.write(' ')
f.read()
( PythonWin 2.3 (#46, Jul 29 2003, 18:54:32) on
win32. )
I got...
|
by: Joseph |
last post by:
Hi,
I'm having bit of questions on recursive pointer. I have following
code that supports upto 8K files but when i do a file like 12K i get a
segment fault. I Know it is in this line of code. ...
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen....
|
by: Mika M |
last post by:
I have made Setup and Deployment Project for my application. This
application uses couble of Crysral Report .rpt -files, so I included
following into Setup and Deployment Project ...
-...
|
by: thjwong |
last post by:
I'm using WinXP with Microsoft Visual C++ .NET
69462-006-3405781-18776, Microsoft Development Environment 2003 Version
7.1.3088, Microsoft .NET Framework 1.1 Version 1.1.4322 SP1
Most developers...
|
by: littlemaster |
last post by:
I have the following code, it is sending text message. I want to attach a file. How to do that?
require 'net/smtp' # plain mail
smtpclient = Net::SMTP::new( '192.168.1.1' ) # create new object to...
|
by: littlemaster |
last post by:
The following program will send the mail with specified attachment file.Need to give the absolute path of the file.
require "rubygems"
require "ruport"
require "ruport/util"
r =...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |