|
Or something like if ( textBox1.Text.EndsWith ( ".csv" ) ) ...
But I would likely use a System.IO.FileInfo and check its Extension property.
|
|
|
|
|
Hi
I have created a .NET application with a custom installer, that all works fine.
After the installation process I need to access a file that is located inside the folder where the MSI installer / setup is located.
The problem I have is I cannot work out how to get the path for the MSI installer / setup.
Can anybody please help and advice me the best way to get this path while I am still inside the "Commmited" of the installer
vb.net or C# either will be fine.
Thanks
|
|
|
|
|
|
Hi,
i want to retrieve some content from a webpage.
The method below retrieve the webpage content (in html).
public string GetWebpageContent(string StockQuote)
{
string serverURL = "http://www.google.com/finance?q=" + StockQuote;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serverURL);
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII);
string retVal = reader.ReadToEnd();
reader.Close();
return retVal;
}
Below method retrieve the stockprice in the web content. the html i wan to read consist this
<div>After Hours: <span class=bld id="ref_21913_el">10.60</span>
I wan to retrieve the value 10.60
The id="ref_21913_el" is not a fix value, so i have to read base on
<span class=bld....
public string GetStockPrice()
{
StringBuilder ReversePrice = new StringBuilder();
string Price = "";
MatchCollection StockQuote = Regex.Matches(urlContent, "", RegexOptions.Singleline);
string StockPriceTag = StockQuote[0].Value;
string WithoutEndSpanTag = StockPriceTag.Remove(StockPriceTag.Length - 7, 7);
for (int i = WithoutEndSpanTag.Length - 1; i >= 0; i--)
{
char[] AllChar = WithoutEndSpanTag.ToCharArray();
if (AllChar[i] != '>')
{
ReversePrice.Append(AllChar[i]);
}
else
{
char[] arr = ReversePrice.ToString().ToCharArray();
Array.Reverse(arr);
Price = new string(arr);
break;
}
}
return tbxStockQuote.Text + ", $" + Price;
}
how do i change my MatchCollection StockQuote = Regex.Matches(urlContent, "<span class=bld(.*?)</span>", RegexOptions.Singleline);
so i can read the 10.60 value?
modified on Monday, November 30, 2009 7:37 AM
|
|
|
|
|
If I were u I, I will change the StockPriceTag string to "<root><span class=\"pr\">\n<span id=\"ref_705173_l\">26.83</span> </root>". Then load it in an XML Document. Where you can simple read the value of Span tag.
Cheers.
|
|
|
|
|
Here's a Regular Expression that will match your span and put the price in a named group:
\<span class=bld id=\"[^\"]*\"\>(?'Price'[\d\.]*)\</span\>
Read up on what Regular Expressions can do.
|
|
|
|
|
Hi,
How to play number of files one by one like playlist using windows media player control.
eg:
i have the following files
music1.mp3, music2.mp3, music3.mp3
when i click a button i need to play each files one after one...
thankyou,
YPKI
|
|
|
|
|
Have a look at the file-format ASX.
Here is a sample, hope that helps.
<ASX VERSION="3.0">
<TITLE>Example Media Player Show</TITLE>
<PARAM NAME="Director" VALUE="Jane D." />
<ENTRY>
<TITLE>Example Clip</TITLE>
<REF HREF="http://example.microsoft.com/media.asf" />
<PARAM NAME="Location" VALUE="North America" />
<PARAM NAME="Release Date" VALUE="March 1998" />
</ENTRY>
<ENTRY>
<TITLE>Another Clip</TITLE>
<REF HREF="http://example.microsoft.com/more_media.asf" />
<PARAM NAME="Location" VALUE="Japan">
<PARAM NAME="Release Date" VALUE="December 1996" />
</ENTRY>
</ASX>
[edit] example modified [/edit]
Greetings
Covean
|
|
|
|
|
hello,
try to use the foreach or the for loop in your list
|
|
|
|
|
Hello,
I want to build speech recognition application for vista and xp too. I am using .net framework 3.5.
I have tried many examples for that but i failed to run. It gives me an error say "the language for the grammar does not match the language of the speech recognizer." , i just don't know exactly where i am getting an error.
Please help me, its urgent.
Thank you in advance.
|
|
|
|
|
I think this fails because the Grammer element for the Culture you specified is not installed properly.
If you just ignore it, the Speech Recognition will works I think.
|
|
|
|
|
Thank you,
i have set culture info to my speech recognition language and it works fine. But i want to know if i want to run same application in xp and vista too, is it possible?
|
|
|
|
|
yes why not.
Same thing will run I guess.
|
|
|
|
|
I am using the following code to import a csv file into a datagridview:
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using System.IO;<br />
<br />
namespace CSVImporter<br />
{<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
List<string[]> csv =<br />
parseCSV("C:\\text.csv");<br />
DataTable newTable = new DataTable();<br />
string[] headers = csv[0];<br />
int counter = 0;<br />
foreach (string column in headers)<br />
{<br />
DataColumn colNewDGCol = new DataColumn();<br />
colNewDGCol.ColumnName = "CSV" + headers[counter];<br />
newTable.Columns.Add(colNewDGCol);<br />
newTable.Columns[counter].HeaderText = headers[counter];<br />
counter++;<br />
}<br />
<br />
foreach (string[] row in csv)<br />
{<br />
newTable.Rows.Add(row);<br />
}<br />
dataGridView1.DataSource = newTable;<br />
}<br />
<br />
public List<string[]> parseCSV(string path)<br />
{<br />
List<string[]> parsedData = new List<string[]>();<br />
<br />
using (StreamReader readFile = new StreamReader(path))<br />
{<br />
string line;<br />
string[] row;<br />
<br />
while ((line = readFile.ReadLine()) != null)<br />
{<br />
row = line.Split(',');<br />
parsedData.Add(row);<br />
}<br />
}<br />
<br />
return parsedData;<br />
}<br />
}<br />
}<br />
<br />
But the line: newTable.Columns[counter].HeaderText = headers[counter];
does not work.
How can I create the appropriate column header text please?
|
|
|
|
|
bonjour,
tu dois faire newTable.Columns[counter].ColumnName = headers[counter];
au lieu de newTable.Columns[counter].HeaderText = headers[counter];
je l'ai testé et j'ai pu afficher les données dans grid view
|
|
|
|
|
Beaucoup de mercis de votre aide. Beaucoup a apprécié.
|
|
|
|
|
For a WinForm application using C#, how to make the form become gray/dark slowly when pop up a dialog? Like XP does when user is going to shut down computer.
Thanks in advance.
|
|
|
|
|
Just open a form maximized with no Titlebar. Make the background of the form black.
Use Opacity of the form below 50, and show the dialog above the form.
I think you will find the same effect.
|
|
|
|
|
|
Is it at all required to produce Grayscale using Bitmap when you can do this easily using Opacity of a form ??
|
|
|
|
|
How can you turn other windows gray by setting opacity of the form?
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Just place the transparent form(with black background) over all other window and set opacity to a value less than 50%... maybe it could animate the opacity from 0 to 50....
It will be done automatically...
|
|
|
|
|
Abhishek Sur wrote: It will be done automatically...
Actually no.
Just tested it and you can still see the colors of the underlaying windows.
All this does is put a grayish 'film' over it but the colors of any window behind it are still very visible.
|
|
|
|
|
Ohh... is it ..
Thanks for letting me know this. I didnt tried that. Thought it would be done this way.
Cheers.
|
|
|
|
|
No. That wont turn the title bar of the windows behind to gray. Background windows will still be olive green (as per my system settings).
You need to use similar mechanism as what XP uses or digg in to Nish's article. Since it is in C++, I don't get much out of it.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|