|
OK - have fun. Did you have a question ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hey Everybody,
I'm havin' a bit of trouble trying to solve a problem here and I've googled for quite a while now and I am tryng to search files on my computer for any URL and get thos URL's into a string... The URL could be anywhere inside the file and I keep getting 1 error when I TRY to debug:
Error 1 The name 'word' does not exist in the current context
Here's the code that I have:
private void SearchButton_Click(object sender, EventArgs e)
{
string FilePath = "C:\\Users\\Jase\\Documents\\dumpFile.txt";
StreamReader ReadFile = new StreamReader(FilePath);
string ReadAll = ReadFile.ReadToEnd();
ReadFile.Close();
string regMatch = "ht|f" + "tp://" <word> ".com" | ".net" | ".org";
if (Regex.IsMatch(ReadAll, regMatch))
{
StatusLabel.Text = (regMatch + " was found.");
}
else
{
StatusLabel.Text = (regMatch + " was not found.");
}
}
j.t.
|
|
|
|
|
plz see if this is added the namespace....
using System.Text.RegularExpressions;
Thanks
tony
|
|
|
|
|
thanks tony,
i did originally add:
using System.Text.RegularExpressions;
I dunno what to do... None of the code I've found on Google so far works either.
j.t.
|
|
|
|
|
jay_t55 wrote: string regMatch = "ht|f" + "tp://" <word> ".com" | ".net" | ".org";
I am not sure what are trying to do here.
As far as your requirement is concerned, I would have used following code:
Regex reg = new Regex(regMatch);
Match oMatch = reg.Match(ReadAll);
Google will easily provide you a regular expression(regMatch) to find a URL in text.
Loading signature. Please wait...
|
|
|
|
|
jay_t55 wrote: string regMatch = "ht|f" + "tp://" <word> ".com" | ".net" | ".org";
Didn't try, but this looks very weird. I'm quite sure this is lacking some blanks and/or brackets.
Tip: Use String.Format instead of + to concat strings. It's much faster (which is not that relevant here) and much more readable.
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
hello all,
i was looking for a better answer from some one who could give answer for my question
i want to get file path of the file csc.exe from the system.
a system may contain one drive c, or many depending on how it is configured.the drives arenot know to me and i want to serch these drives to get the file path HOW??
finding how many drives in the system first... and make a search for the file (csc.exe)... plz HELP URGENT... on for project completion by this friday.....
TONY
|
|
|
|
|
You can enumerate all the drives on your system and then recurse through the directories until you find the file.
tonyjsebastian1 wrote: was looking for a better answer
So, you've been told this already then ?
tonyjsebastian1 wrote: plz HELP URGENT
You have no idea how much this annoys us...
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
hello
sorry to disturb u. i am not an expert in coding C#... i just started only and facing real difficulties so i posted such a question
don't misunderstand me
i was looking for a better answer .. ie i got the answer from Mikro1980
see below code snippet. it really targeted on me for what i was exactly looking for
string csc = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory().ToString();
Thanks & Regards
Tony
|
|
|
|
|
Hi,
I'm afraid there isn't a simple answer to your question; here are some facts:
1. csc.exe belongs to a specific version of the .NET Framework i.e. for each version you install you get another csc.exe file
2. you should use the one that goes with your running .NET application (check Environment.Version) or that fits the framework you want to target
3. the .NET versions reside under the Windows folder, in the Microsoft.NET subfolder
4. The current Windows folder is specified by the environment variable "windir" (which typically contains C:\Windows); check Environment.GetEnvironmentVariables()
5. the different versions of .NET inside the "Microsoft.NET" each have their own subfolder, but the naming conventions of these have changed over time.
6. the following links might be useful:
http://msdn.microsoft.com/en-us/library/dc98ytx2.aspx[^]
http://support.microsoft.com/kb/318785[^]
Hope this is sufficient.
|
|
|
|
|
hello, Luc Pattyn
thanks for u r reply to my question
the problem what i faced is in my c# application is i want to make a file to be get executed by calling the cse.exe.
for this what i did is in the code below
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\csc.exe";
the pproblem is i shfted the application to a new system and the code does not worked thr.
i came to know that the cse.exe was not in that systems C drive...
so want to find how to get the path for the csc.exe fie ...
i think u understood what i exactly mean???
Mikro1980 helped me now with a code
string csc = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()+"csc.exe".ToString();
i think this would help in my case... i am trying on that
any way
Thanks & Regards
Tony
|
|
|
|
|
Sorry, I was not aware of that method. It seems to be exactly what you need, and
I'm glad to have learned this today.
Cheers.
|
|
|
|
|
Hi,
In my application I am reading an image and storing in the byte[], this value is added in the hashtable for accessing in another class, now i need to access the byte[] present in the hashtable and display the image back,
Can any one give me an idea how this can be done,
I tried doing with the following code
byte[] myByteArray = (byte[])htnew["CoalMill1"];
MemoryStream ms = new MemoryStream(myByteArray,0,myByteArray.Length);
Bitmap bmp = (Bitmap)Bitmap.FromStream(ms);
bmp.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
here htnew is the hashtable which has a byte value of the image.
but i get "Parameter not valid" error.
any other ways to fetch the image back from hashtable
Thanks,
|
|
|
|
|
Why do you need to cast the result as byte[] ? Shouldn't it be that already ?
There's no other way to get data from a hash table, the odds are, your data is broken.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
since my appplication requirement is to create a window service and store the image , I am using the hashtable to maintain the image data, but while fetching using the above given code i get error,
I have a doubt like while storing the image in hashtabel i am initailizing the byte to 1024 , will that create any error of this type.
the code is given here:
ie reading from stream and storing as byte[]
Stream remoteStream = response.GetResponseStream();
byte[] buffer = new byte[1024];
int bytesRead;
do
{
readerWriter.AcquireWriterLock(5000);
bytesRead = remoteStream.Read(buffer, 0, buffer.Length);
readerWriter.ReleaseWriterLock();
} while (bytesRead > 0);
now adding the byte[] value in the hashtable present in another class.
ImageServer.ht.Add(strCameraName, img);
Thanks,
|
|
|
|
|
Why would you decompress the data into a Bitmap, only to compress it into binary data again on the next line? Just write the byte array to the response stream.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi, i have error" Data type mismatch in criteria expression" when execute : clsADONET.setConnCommand_Close(sCommand) . Can explain for me what's wrong? here is the code. thanks
public void Update()
{
try
{
string cmd;
string field;
string parameter;
field = "Site,Model”;
parameter = "@Site,@model”;
cmd = "INSERT INTO Run(" + field + ") values (" + parameter + ")";
clsADONET.setConnCommand_Open(sCommand);
sCommand.CommandText = cmd;
sCommand.Parameters.Add("@Site", OleDbType.VarChar, 20);
sCommand.Parameters.Add("@Model", OleDbType.VarChar, 20);
sCommand.Parameters["@Site"].Value = CS.site;
sCommand.Parameters["@Model"].Value = CS.DUTSelected.ToString();
clsADONET.setConnCommand_Close(sCommand);
}
catch(Exception e)
{
MessageBox.Show(e.Message);
return;
}
}
class clsADONET
{
public static OleDbConnection sConnection = new OleDbConnection();
public static OleDbCommand sCommand = new OleDbCommand();
public static OleDbDataAdapter sAdapter = new OleDbDataAdapter();
public static void setConnCommand_Open(OleDbCommand sCommand)
{
setConnection(CommunicationSettings .DatabaseonServer);
sConnection.Open();
sCommand.Connection = sConnection;
}
public static void setConnCommand_Close(OleDbCommand sCommand)
{
try
{
sCommand.ExecuteNonQuery();
sCommand.Parameters.Clear();
sCommand.Connection.Close();
sConnection.Close();
}
catch (Exception e)
{
clsLog.LogEvent("Error", "", "Module:setConnCommand_Close(clsADONET.cs) ", e.Message, CommunicationSettings.EventNo);
}
}
public static void setConnection(string dataBaseLocation)
{
if (sConnection.State == ConnectionState.Open) sConnection.Close();
sConnection.ConnectionString = setConnectionString(dataBaseLocation, "");
}
}
|
|
|
|
|
Ok, I am not sure how to explain what i want but i will give it a go. Do you know those electronic circuit analysis programs where you can drag a resistor onto a page and construct a circuit? There are many other engineering programs that work in a similar way and perform calculations based on your design. I want to make an environment where i can construct a circuit. Is there an easy way to do this. Or is there any similar code i can use?
|
|
|
|
|
I'd imagine a base 'object' class, and then derived objects that represent resistors, etc. These would be added to a collection of objects as they are dropped on the screen. Calculating what the circuit created is, and so on, would be a whole bunch of work on top of that, obviously.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Paper clip: I see you are creating a transister radio; would you like some help with that?
|
|
|
|
|
*grin* NOW you're talking.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
PIEBALDconsult wrote: Paper clip
*shotgun* BANG, oh damn another screen gone......
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
if shooting monitors is a habit of yours, you should consider buying those new OLED ones.
They are organic, so given the right amount of nutrients and water may make them recover from modest shot wounds.
|
|
|
|
|
much cheaper to banish clippy to the pits of hell....
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
That won't cut it, if you dismiss Clippy then Rocky or one of his friends will haunt you.
|
|
|
|