Hai,,
I need to implement progressbar in my application,It may be simple.
but i am confusing with this.i am just a biginner,so kindly help me anyone.
my requirement with progress bar is that
in a button click ,there is 3 more if loop in that..i have to
implement progress bar in each if loop. my program is converting the utf files into
hexadecimal,character and decimal format according to the selected file type.
for eg: i am selecting a folder,that folder may contain 1 or more .html files. i have to
convert this .html utf files to other 3 format as per the selected radio button.
in this case i need to implement progressbar
and show the progress while completing the conversion of selected files..
In this below program how to implement progressbar. i want to show the progress of the conversion of each files in progressbar...Anyone please help me..
if (rbtn_InputUtf.Checked == true && rdo_HexaDecimal.Checked == false && rdo_Character.Checked == true && rdo_Decimal.Checked == false)
{
string[] filesCollection = Directory.GetFiles(folderBrowserDialog1.SelectedPath);
foreach (string files in filesCollection)
{
string fileType = Path.GetExtension(files);
if (fileType == comboBox1.SelectedItem.ToString())
{
sr = new StreamReader(files);
while ((line = sr.ReadLine()) != null)
{
line = obj2.ReplaceToCharacterTag(line);
sb.AppendLine(line);
i++;
string path = Path.GetFullPath(folderBrowserDialog1.SelectedPath);
DirectoryInfo r = new DirectoryInfo(path);
DirectoryInfo df = r.CreateSubdirectory("Output");
DirectoryInfo dfOutSub = df.CreateSubdirectory("Utf to Character");
string getFilename = Path.GetFileName(files);
path = Path.Combine(dfOutSub.ToString(), getFilename);
StreamWriter writer = new StreamWriter(path);
writer.WriteLine(sb.ToString());
writer.Close();
}
}
sb.Length = 0;
}
MessageBox.Show("Completed", "Status");
}
if (rbtn_InputUtf.Checked == true && rdo_HexaDecimal.Checked == false && rdo_Character.Checked == true && rdo_Decimal.Checked == false)
{
string[] filesCollection = Directory.GetFiles(folderBrowserDialog1.SelectedPath);
foreach (string files in filesCollection)
{
string fileType = Path.GetExtension(files);
if (fileType == comboBox1.SelectedItem.ToString())
{
sr = new StreamReader(files);
while ((line = sr.ReadLine()) != null)
{
line = obj2.ReplaceToCharacterTag(line);
sb.AppendLine(line);
i++;
string path = Path.GetFullPath(folderBrowserDialog1.SelectedPath);
DirectoryInfo r = new DirectoryInfo(path);
DirectoryInfo df = r.CreateSubdirectory("Output");
DirectoryInfo dfOutSub = df.CreateSubdirectory("Utf to Character");
string getFilename = Path.GetFileName(files);
path = Path.Combine(dfOutSub.ToString(), getFilename);
StreamWriter writer = new StreamWriter(path);
writer.WriteLine(sb.ToString());
writer.Close();
Progressbar1.value+=10; //if number of files is 10 it will reach to 100 in 10 loops sw you have to increment 100/no_of_files
}
}
sb.Length = 0;
}
MessageBox.Show("Completed", "Status");
}
If you feel helped. Please mark this post as Answer
From my program i get the no of files after foreach loop. from that i get the file number one by one.ouside the foreach loop i get total no of files. and also how will i put
Progressbar1.value+=10; inside while loop?. because that loop will execute the same times as how many no of lines in a file.
Anyone Plz Help me to solve this issue with progressbar
The progress in progressbar is not getting correctly,,Is there any expert to help me for fix this problem ? i am troubling with this many days..How can do this?
v-ambily
Member
155 Points
141 Posts
Problem with progress bar
Mar 23, 2012 12:03 PM|LINK
Hai,,
I need to implement progressbar in my application,It may be simple.
but i am confusing with this.i am just a biginner,so kindly help me anyone.
my requirement with progress bar is that
in a button click ,there is 3 more if loop in that..i have to
implement progress bar in each if loop. my program is converting the utf files into
hexadecimal,character and decimal format according to the selected file type.
for eg: i am selecting a folder,that folder may contain 1 or more .html files. i have to
convert this .html utf files to other 3 format as per the selected radio button.
in this case i need to implement progressbar
and show the progress while completing the conversion of selected files..
Thanks in advance..
tdmca
Contributor
2396 Points
661 Posts
Re: Problem with progress bar
Mar 23, 2012 12:09 PM|LINK
I think you have to reach to progress bar's maximum level in number of files in folder.
and you are looping for same number of time
if there a are 10 files and maximum of PB is set to 100 then you will loop 10 times.
In loop just add one line at last to increment the value property by 10.
and tell me if it helped ?
v-ambily
Member
155 Points
141 Posts
Re: Problem with progress bar
Mar 24, 2012 09:36 AM|LINK
Hai....
In this below program how to implement progressbar. i want to show the progress of the conversion of each files in progressbar...Anyone please help me..
if (rbtn_InputUtf.Checked == true && rdo_HexaDecimal.Checked == false && rdo_Character.Checked == true && rdo_Decimal.Checked == false)
{
string[] filesCollection = Directory.GetFiles(folderBrowserDialog1.SelectedPath);
foreach (string files in filesCollection)
{
string fileType = Path.GetExtension(files);
if (fileType == comboBox1.SelectedItem.ToString())
{
sr = new StreamReader(files);
while ((line = sr.ReadLine()) != null)
{
line = obj2.ReplaceToCharacterTag(line);
sb.AppendLine(line);
i++;
string path = Path.GetFullPath(folderBrowserDialog1.SelectedPath);
DirectoryInfo r = new DirectoryInfo(path);
DirectoryInfo df = r.CreateSubdirectory("Output");
DirectoryInfo dfOutSub = df.CreateSubdirectory("Utf to Character");
string getFilename = Path.GetFileName(files);
path = Path.Combine(dfOutSub.ToString(), getFilename);
StreamWriter writer = new StreamWriter(path);
writer.WriteLine(sb.ToString());
writer.Close();
}
}
sb.Length = 0;
}
MessageBox.Show("Completed", "Status");
}
Thanks in advance
v-ambily
Member
155 Points
141 Posts
Re: Problem with progress bar
Mar 26, 2012 11:34 AM|LINK
Hiiii,
Anyone please help me to give the idea about the progressbar
Thanks
tdmca
Contributor
2396 Points
661 Posts
Re: Problem with progress bar
Mar 26, 2012 03:59 PM|LINK
if (rbtn_InputUtf.Checked == true && rdo_HexaDecimal.Checked == false && rdo_Character.Checked == true && rdo_Decimal.Checked == false)
{
string[] filesCollection = Directory.GetFiles(folderBrowserDialog1.SelectedPath);
foreach (string files in filesCollection)
{
string fileType = Path.GetExtension(files);
if (fileType == comboBox1.SelectedItem.ToString())
{
sr = new StreamReader(files);
while ((line = sr.ReadLine()) != null)
{
line = obj2.ReplaceToCharacterTag(line);
sb.AppendLine(line);
i++;
string path = Path.GetFullPath(folderBrowserDialog1.SelectedPath);
DirectoryInfo r = new DirectoryInfo(path);
DirectoryInfo df = r.CreateSubdirectory("Output");
DirectoryInfo dfOutSub = df.CreateSubdirectory("Utf to Character");
string getFilename = Path.GetFileName(files);
path = Path.Combine(dfOutSub.ToString(), getFilename);
StreamWriter writer = new StreamWriter(path);
writer.WriteLine(sb.ToString());
writer.Close();
Progressbar1.value+=10; //if number of files is 10 it will reach to 100 in 10 loops sw you have to increment 100/no_of_files
}
}
sb.Length = 0;
}
MessageBox.Show("Completed", "Status");
}
v-ambily
Member
155 Points
141 Posts
Re: Problem with progress bar
Mar 27, 2012 07:26 AM|LINK
Hai tdmca,
From my program i get the no of files after foreach loop. from that i get the file number one by one.ouside the foreach loop i get total no of files. and also how will i put Progressbar1.value+=10; inside while loop?. because that loop will execute the same times as how many no of lines in a file.
Anyone Plz Help me to solve this issue with progressbar
Waiting for the quick response
Thanks in advance
tdmca
Contributor
2396 Points
661 Posts
Re: Problem with progress bar
Mar 30, 2012 06:53 PM|LINK
ok now i got.
you have to find the number of lines
Progressbar1.value+=10 // you have to increment with 100/number of lines
tdmca
Contributor
2396 Points
661 Posts
Re: Problem with progress bar
Mar 30, 2012 06:55 PM|LINK
this will be for one file after one file process completion again initialize it to zero
if you want a overall progressbar which cover 0 to 100 when all files get converted then
Progressbar1.value+=10 // you have to increment with 100/(number of lines*no of files)
v-ambily
Member
155 Points
141 Posts
Re: Problem with progress bar
Apr 06, 2012 06:08 AM|LINK
Hai,
The progress in progressbar is not getting correctly,,Is there any expert to help me for fix this problem ? i am troubling with this many days..How can do this?
Thanks in advance