|
Streamwriter writes out text to a target - you can specify encoding for it but it doesn't write out the font stuff - just text.
Now, if you had your text in a RichTextBox, you could save the contents to an RTF file using the SaveFile() method.
I'm sure if I'm incorrect here, someone will step in and let me know.
Good luck.
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
Hello Matthew,
I have the text in a wordpad and I have to write it back to the file.
Appreciate your help!
D
|
|
|
|
|
Which is the best way to store a dataset over a page?
Session, Cache or Viewstate?
Thanks
|
|
|
|
|
its obviousely that cache is better to other because session or viewstate has limited and access to them is not suitable for large data
nobody help you...
you have to help you yourself
and this is success way.
|
|
|
|
|
Hi,
I am creating a custom web browser. For that I need to make a custom search function. The problem is that I am unable to create text ranges from framed pages such as wikipedia articles. The code is as follows. I would appreciate any help:
//function to find a given string in the page
public int findString(string wordToFind, int myIndex)
{
MSHTML.IHTMLDocument2 htmldom = (MSHTML.IHTMLDocument2)wBrowser.Document.DomDocument;
IHTMLElement outerMostElement;
IHTMLDocument2 doc = (IHTMLDocument2)wBrowser.Document.DomDocument;
if (wBrowser.Document.Body.Parent.ClientRectangle.IsEmpty) {
outerMostElement = doc.body;
}
else {
outerMostElement = doc.body.parentElement;
}
//Create the range
MSHTML.IHTMLTxtRange range1 = MSHTML.IHTMLTxtRange)((MSHTML.IHTMLBodyElement)outerMostElement).createTextRange();
//CType(htmldom.selection.createRange(), MSHTML.IHTMLTxtRange)
//Get the initial start point of the text range
if (range1.text.Substring(myIndex).IndexOf(wordToFind) != -1) {
myIndex = range1.text.Substring(myIndex).IndexOf(wordToFind) + myIndex;
range1.moveStart("character", myIndex);
frmSearch.Hide();
this.Activate();
range1.findText(wordToFind, 0, 0);
range1.select();
//set the start position of the range for te next try
myIndex += wordToFind.Length;
range1.collapse();
return myIndex;
}
else {
return -1;
}
}
Ahmad
|
|
|
|
|
Hi All. I am trying to use process.start but I am getting a file not found exception.
Here is the code - I broke it down to try and find out where the error was:
<br />
strArgs = DateTime.Now.AddMonths(-1).ToShortDateString();<br />
strArgs = strArgs.PadLeft(10,'0');<br />
strArgs = strArgs.Remove(2,4);<br />
file = file.PadLeft(2,'0');<br />
strArgs = " d:\\EOM\\EOM" + file + strArgs + ".ZIP";<br />
path = " d:\\eom\\" + file + "\\*.m*";<br />
strArgs = strArgs + path;<br />
strArgs = "c:\\Progra~1\\Winzip\\wzzip.exe " + strArgs; <br />
myProcess.StartInfo.FileName = strArgs; <br />
myProcess.StartInfo.CreateNoWindow = true;<br />
try<br />
{<br />
blTest = myProcess.Start();<br />
}<br />
catch (SystemException caught)<br />
{<br />
Console.WriteLine(caught.ToString());<br />
}<br />
The strArgs = @"c:\Progra~1\Winzip\wzzip.exe d:\EOM\EOM01082007.ZIP d:\eom\01\*.m*"
from the debugger. If I copy the string from the debugger into the run box of windows, it runs fine.
What am I missing?
Jude
|
|
|
|
|
You are passing in the short path name here which is a convenience for running from the command line. This is a hangover from the old days when you could only have 8 characters in a filename or directory name. You need to replace this with c:\\program files\\winzip\\ and so on.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanx for the quick reply, but that's where I started. I changed it to see if that could have been a problem.
Jude
|
|
|
|
|
I could use this:
Process.Start("c:\\Program Files\\Winzip\\wzzip.exe ",strArgs)
Which works, but I come into a problem there. This code is going through a loop. It executes the line x many times then continues on with the next line of coe. The next line of code uses the files names just created. One small problem - the processes have not finished yet so therefore the is no file names to work with.
Is there a way to check if the process started by Process.Start is finished before moving on to the next one?
Jude
|
|
|
|
|
TheJudeDude wrote: Is there a way to check if the process started by Process.Start is finished before moving on to the next one?
Yes there is. You can use either Process.HasExited Property to determine that or Process.WaitForExit method to wait for a process exit.
<br />
Process myproc=Process.Start("c:\\Program Files\\Winzip\\wzzip.exe ",strArgs);<br />
<br />
if(myproc.HasExited)<br />
{<br />
}<br />
else<br />
{<br />
}<br />
Or
<br />
Process myproc=Process.Start("c:\\Program Files\\Winzip\\wzzip.exe ",strArgs);<br />
<br />
myproc.WaitForExit(); <br />
WaitForExit() waits an infinite amount of time for the process to exit. This can cause an application to stop responding so I recommend you use overload ofWaitForExit which except amount of time to wait for and returns a boolean value indicating whether the process has exited or not
|
|
|
|
|
TheJudeDude wrote: Hi All. I am trying to use process.start but I am getting a file not found exception.
Here is the code - I broke it down to try and find out where the error was:
strArgs = DateTime.Now.AddMonths(-1).ToShortDateString();
strArgs = strArgs.PadLeft(10,'0');
strArgs = strArgs.Remove(2,4);
file = file.PadLeft(2,'0');
strArgs = " d:\\EOM\\EOM" + file + strArgs + ".ZIP";
path = " d:\\eom\\" + file + "\\*.m*";
strArgs = strArgs + path;
strArgs = "c:\\Progra~1\\Winzip\\wzzip.exe " + strArgs;
myProcess.StartInfo.FileName = strArgs;
myProcess.StartInfo.CreateNoWindow = true;
try
{
blTest = myProcess.Start();
}
catch (SystemException caught)
{
Console.WriteLine(caught.ToString());
}
From reading the documentation, it looks to me like StartInfo.FileName should just contain
"c:\\Program Files\\Winzip\\wzzip.exe" and the rest of the arguments should be put in StartInfo.Arguments
Nathan
|
|
|
|
|
Thanx Nathan that worked. I was going to use the boolean value to see if the process was finished, but this is obviously not the intended purpose.
Could anyone give me an idea on how to find out if a process started with process.start is finished?
Jude
|
|
|
|
|
I have just answered your question a little bit above
|
|
|
|
|
|
Glad to help you
|
|
|
|
|
Well, if you glad to help, one more question.
The MSDN documentation sometimes has me dumbfounded. Where could I get a thorough book on the .net framework?
I dabble in linux with scripts in bash, windows with VS, and a few old skool database management systems, along with being the tech support guy for a 25 location company, so I am not always at the keyboard coding away. IOW - I should/could have found that answer myself, but did not through the MSDN documentation.
I would love a comprehensive desk reference on the .net framework.
Thanx
Jude
|
|
|
|
|
|
hi
i want to playBack video as streaming, but how to do ?
thanks
|
|
|
|
|
Launch Media Player and tell it where to get the stream from.
If you want a more thorough answer, post a more thorough question.
|
|
|
|
|
you are mean that i use Windows Media Player ?
if yes how to use it for playBack video as stream ?
thanks
|
|
|
|
|
Hi,
Im using Visual Studio 2005 and .Net 3.0. I wanted to apply Break Points in my Custom Attribute class. I and my falla both used number of sample code but code is not executing Custom class nor break points work.
Here is someone sample code. Im not able to apply Break point.
Can anyone knows the answer?
<br />
namespace RegKeyAttributeTestor<br />
{<br />
[AttributeUsage(AttributeTargets.Method|AttributeTargets.Struct,<br />
AllowMultiple=false,Inherited=false)]<br />
public class MyAttribute:Attribute<br />
{<br />
private string regKey="a12nf";<br />
public MyAttribute(string regKey)<br />
{<br />
if(this.regKey==regKey)<br />
{<br />
Console.WriteLine("Permitted to use this App");<br />
}<br />
else<br />
{<br />
Console.WriteLine("Not registered to use this App");<br />
}<br />
}<br />
}
class useAttrib<br />
{<br />
[MyAttribute("hello")]<br />
public static string SayHello(string str)<br />
{<br />
return str;<br />
}<br />
static void Main()<br />
{<br />
Console.WriteLine(SayHello("Hello to Sufyan"));<br />
Console.ReadLine();<br />
}<br />
}<br />
<br />
}<br />
Thanks ,
sha
|
|
|
|
|
Sha Sea wrote: Hi,
Im using Visual Studio 2005 and .Net 3.0. I wanted to apply Break Points in my Custom Attribute class. I and my falla both used number of sample code but code is not executing Custom class nor break points work.
Here is someone sample code. Im not able to apply Break point.
Can anyone knows the answer?
I believe the custom attribute code would be executed at compile time rather than run time, so by the time the debugger starts, the attribute constructor has already been executed. Also, you couldn't use the attribute to authorize someone to use the code because the code would just be executed on your machine, and the resulting attribute object would just be included in the executeable file.
Nathan
|
|
|
|
|
Thankx.
Even i put the MessageBox.Show() it is not showing anything.
Its weird thing for me.
What do you say?
Thanks,
sha
|
|
|
|
|
Sha Sea wrote: Thankx.
Even i put the MessageBox.Show() it is not showing anything.
Its weird thing for me.
What do you say?
You could test the code in an attribute class by creating an object with new . Another possibility is to not use attributes for what you're doing.
Nathan
|
|
|
|
|
hello!
plz can some body tell me in c# how can i delete a file used by another process?
i'm trying to delete a file by:
File.Delete(@"C:\test.txt");
a System.IO.IOException appear:
"cannot acess the file because it is being used by another process."
I don't know where in my application i'm using this file, but i need to delete it.
thank you
Best Regards,
Jimmy.
|
|
|
|