|
This regex will work just fine:
((\w+)\s*=\s*\(\s*\2\s*\+\s*1\s*\))
with the replacement string
$2++
You need to replace \w+ with a proper pattern for only valid variable names though.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
But it's wrong. Yours will also match
x = (y + 1)
because no backreference to the first variable is used for the second, so both variables might not necessarily be the same, which violates the rule i=i+1 <=> i++
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
hi,
I am triying to assing values dynamically toa array string here i am triying to write
code as follows
this.openFileDialogimage.ShowDialog().Equals(DialogResult.OK);
string drname = Path.GetDirectoryName(this.openFileDialogimage.FileNames[0]);
foreach (string file in this.openFileDialogimage.FileNames)
{
int i;
for (i = 0; i <= Convert.ToInt32(openFileDialogimage.FileNames.Count()); i++)
{
string[] str = new string[Convert.ToChar(openFileDialogimage.FileNames.Count())];
}
}
help me how to procede,
how i can send the file name which has be selected in open dialog box to a string .
Regard's,
Maruthi.
|
|
|
|
|
The FileNames property already returns an array of strings, so all you need is:
if (this.openFileDialogimage.ShowDialog() == DialogResult.OK) {
string[] str = this.openFileDialogimage.FileNames;
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
Using its filename property.
|
|
|
|
|
I am on a multi threaded application which is a file downloader from FTP server. I have created a producer/consumer style custom class which manages a download queue and processes the items one by one in the queue. I am adding delegate instances to the queue and when one thread picks the item, it invokes the delegate instance to start the work.
For downloading files from FTP, I used WebClient classes DownloadFileAsync . My custom class wraps webclient and it's events. I have noticed this is downloading only 2 files at a time. All the other requests are queued and will be executed one by one.
My "DownloadQueue" class is working well. It creates the specified number of threads and dequeues each item when threads become free. I found problem is in DownloadFileAsync method of WebClient . It uses asynchronous fashion and obviously using a thread pool thread to download the file. I learned that, thread pool creates only 2 threads by default and all the other requests will be queued until threads become free. I tried increasing the thread count by ThreadPool.SetMinThread() , but it didn't worked. Still it's downloading only two files at a time.
I am sure I have called DownloadFileAsync 5 times from 5 threads. 2 of them started immediately and remaining 3 gets queued. Any idea to solve this issue ?
|
|
|
|
|
N a v a n e e t h wrote: I have noticed this is downloading only 2 files at a time.
How many CPU cores you have? Async calls normally utilize the cores (via ThreadPool, dont know details exactly). Use 'direct' threading to do more.
|
|
|
|
|
Thanks Leppie,
I am on a core2duo machine.
leppie wrote: Use 'direct' threading to do more.
As I said, I am using WebClient classes DownloadAsync method. It works in asynchronous fashion. Looks like I have to implement FTPWebRequest class manually than using WebClient. Any other ideas ?
|
|
|
|
|
N a v a n e e t h wrote: Looks like I have to implement FTPWebRequest class manually than using WebClient. Any other ideas ?
You dont have to.
Just use WebClient synchronously within a Thread of its own.
|
|
|
|
|
leppie wrote: Just use WebClient synchronously within a Thread of its own.
Thanks again leppie.
It won't report progress. I need to update my view (progress bar) too.
|
|
|
|
|
Could it be a limit on the FTP server? Maybe it blocks more than 2 requests from the same IP address (to ensure QOS)?
|
|
|
|
|
Thanks Senthil.
I am testing on local FTP and it allows around 1000 connection simultaneously. Any ideas ?
|
|
|
|
|
Hi
I work at a cancer department and we are using a planning system to plan the radiation therapy for the patients. Some of the data from the planning system can be exported, but it only exports it in Excel 4.0 Worksheet format. I am trying to write an application that can automate some processes. We do not have easy access to these Excel files and what I am trying to do is to have my C# application copy all the data on a worksheet in this Excel 4.0 file and paste it into a new Excel 2003 worksheet where we can manipulate the date.
I am using the following code to copy the data into the clipboard:
Excel.Application objApp = new Microsoft.Office.Interop.Excel.Application();
Excel.Workbook theWorkbook = objApp.Workbooks.Open(excelFile,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value);
Excel.Sheets sheets = theWorkbook.Worksheets;
Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);
range = worksheet.get_Range(startCell, endCell);
range.Copy(Type.Missing);
When I run this and selects the Excel 4.0 file it comes up with the following error:
"External table is not in the expected format."
When I run the code and accesses Excel 2003, then it works fine. It seems to be a Excel version issue.
I am using Visual Studio 2005.
Does anyone know how I can access the data in Excel 4.0?
Thanks.
Kobus
|
|
|
|
|
You'll probably need older version of the Microsoft Office Dlls to access older versions of Excel, but you'll probably have a hard time finding them for Excel 4 seeing as it predates .Net by 10 years
|
|
|
|
|
how to call java script in c#.net application
Like this we call java script Function
Button1.Attributes.Add("onclick()", "return validate();");
modified on Friday, June 27, 2008 6:22 AM
|
|
|
|
|
I'm assuming you're talking about an asp.net program, in which case you're probably best asking over at the asp.net[^] forum.
(If you're not, I don't think it's possible to call a JavaScript from C#, JavaScript is an interpreted language and therefore requires a interpretor, which is usually part of a browser. You could use a web browser control and put the html/javascript in that I suppose. What is it you're trying to do?)
Simon
|
|
|
|
|
It is possible to run a javascript file from the command line using Windows Script Hosting (wsh).
|
|
|
|
|
Good thought.
Although why on earth would you want to...code reuse I suppose...
Simon
|
|
|
|
|
Simon Stevens wrote: code reuse I suppose...
|
|
|
|
|
Hello,
I have created installer for my project using setup project of VS2008 IDE.
Now, i want to send a updated dll so how can i create a patch which can replace the dll at given location?
Thanks in advance
|
|
|
|
|
|
Hehe, I think you replied to the wrong post
|
|
|
|