|
how to delete the text file contents using C#
minchoo
|
|
|
|
|
Two options (presuming you want a blank file and not a non-existant file).
You can delete the file using System.IO.File.Delete (or maybe it's remove) and then recreate it using System.IO.File.WriteAllText(filename, "")
You can open the file for writing and not write anything to it (just don't open it for appending).
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
Im developing an appliction in C# 2.0.consider a situation in which there are multiple projects in a solution and one project's dll(which v get after compiling it) is refrenced by other projects in that solution.All the build information of a project is present in .csproj file of that proj for compilation of project.In the situation, mentioned above,as there is dependency of all other projects on the dll of another project in the same solution,in this case there is a tag in .csproj file with the name <projectreference> that contains path info of refered dll.
But if a project has the reference of the dll that is not in the same solution,then in this case path of that dll is present in the tag <hintpath> instead of <projectreference> in .csproj file of that project.so now i have to ask that am i right?i mean that whether i have extracted this information rightly.if not then plz can u tell what in actual happens because this information is requred in one of my applications,thanks
|
|
|
|
|
Um, if I managed to read that correctly then yes you have extracted the correct information. I think, you might want to explain a bit clearer with a few short examples in future.
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
Hi all,
i have downloaded a chat application from http://www.codeproject.com/useritems/Instant_Messenger.asp
Now i want to add the text formatting for the messages.
Formatting such as Bold, Italics, Underline and Color, Font changes etc.
I tried by using RichtextBox but i am not able to send and receive messges.
Anyone please help me out...
Thanks & Regards,
Pramod
|
|
|
|
|
Yadav Pramod wrote: I tried by using RichtextBox but i am not able to send and receive messges.
Hello Yadav,
Have u send/receive Text or Rtf?
regards,
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
i send the RTF of the richtextbox,
but when i receive the message and try to append the received string to the rtf of the richtextbox by richtextbox1.Rtf += receivedMsg;
here receivedMsg is the rtf that the client has sent.
but the above line does not append the message to the richtextbox.
Thanks,
Pramod
|
|
|
|
|
Yadav Pramod wrote: richtextbox1.Rtf += receivedMsg;
Do not do like this.
Make sure caret are at the end of RTxtBox. & use
richtextbox1.SelectedRtf = receivedMsg;
It will insert text where the caret is.
|
|
|
|
|
Thanks for your quick reply,
this one works in a sample application,
Now i will try that in my chat application.
Thanks,
Pramod
|
|
|
|
|
hi frnds, i m creating a project in visual studio 2005 at home. but in my college vs2003 is installed, so please tell me the way how to open that project in college...
|
|
|
|
|
I don`t know if that is posible because VS 2005 has a different way of managing source files within the project. For an example in VS 2005 if you add a new form to the project, it will be represented by to files, one containig your code and one containing autogenerated code like filed init and stuff like that. However in VS 2003 all the code was in a single file.
|
|
|
|
|
It is not possible. You cannot open a newer version of solution using an old version fo Visual Studio.
The only way you can do is create a new solution under VS2003 and add each file *.cs, *.resx, ... to this solution.
That's why, you must write your code as clean as possible. That means you can use your code in VS2003 and VS2005. Without something specific from VS2005.
|
|
|
|
|
hello frnds, i m creating a dataset at runtime..
for eg.
DataSet ds=new DataSet();
ds.Tables.Add(dt); //where dt is datatable created at runtime...
grid.DataSource=ds;
using the about lines ok code, i m able to view the data in datagrid...
but i want to display that data using crystal reports... how to display that dataset created at runtime using crystal reports...
|
|
|
|
|
iam having the problem of deployment at the client place,ie:at present at the client side iam installing the s/w or setup file seperately ,framework and database saperately.but,in my organization they want a setup in a CD, which should contain framework setup,application setup and database.in a clear way they want as ,when i insert a CD( contains framework setup,application setup and database) in a client machine it should automatically install the framework if it does not have the framework and it will install the application and create complete
database by simply clicking next...next buttons.wheather i can do this,if possible plz give me the description and clear way of setup.
|
|
|
|
|
open ur project,
click to add new project and select setup N deployment ,,
give a name...
thin in solution explorer u find d same...
right click it and click add then project output...
select the first 4 items...(that depends on ur choice)..
then once more click the setup in solution explorer and click build...
u san find a setup folder in ur project folder...
|
|
|
|
|
Hi.
Can anyone give me a simple implementation of Real-time Transport Protocol ?
Best wishes
|
|
|
|
|
|
1) Do your own work, we don't have time to do it for you
2) Have you ever heard of Google[^]?
-- modified at 5:59 Thursday 27th July, 2006
|
|
|
|
|
Hi
In my project i need to implement icon overlay for selected files and folders in a file system.When u right click on a file/folder and select a context menu the icon of the file/folder must be overlayed with a small icon.
I am new to windows shell programming and dont have enough time to do R&D.Searched the net but couldn't find any solution.Found one solution in DotNet247.com but it's not complete code.
can anyone help me.If possible post the code.
Regards
Krishna Choudary
|
|
|
|
|
i save my application settings in a settings.xml file. The settings.xml is editable with any text editor and therefore i always have to consider the fact the settings could ha been mnaullly edited. Is there a way io could encode or something my settings.xml so that the user cant see the the actual content. Also, how can i check wether my file has been modified.
|
|
|
|
|
I think you can create a hash for your file and put it at the beginning.
Then the next time you want to load that file, you must first create
a hash from it and compare it with the hash in you XML file. If it is the
same, then your file is not editted. Otherwise, someone has edit your file.
Use MD5ServiceCryptoProvider.
|
|
|
|
|
Iam working on MDI application and I have some problem.
For the main form, IsMdiContainer is set to true as well as the MdiParent for child form, is set to 'this' (main form).
But problem starts here.
I put all the codes for each controls in each separete class so it's easy to manipulate.
In Tabs class, I have all the methods, properties I need for adding, removing, renaming etc. tabs.
I also have a method for adding new child forms.
In this method, MdiParent isn't set to 'this', but to frmMain.ActiveForm.
The thing is that everything works great unless I try to add new tab from the other Form.
App then breaks at line MdiParent = frmMain.ActiveForm with this error:
Form that was specified to be the MdiParent for this form is not an MdiContainer.<br />
Parameter name: value.
How can I workaround this problem, but still have this method for adding new child forms in Tabs class?
Iam out of ideas.
Sorry if my post is confusing.
|
|
|
|
|
Hi,
ActiveForm is a static property of the Form class that returns currently activated form for the application but not the acitve frmMain instance. So in some cases you try to bind child form to the non-MDI-parent form.
To have access to your frmMain form from all your classes you can add static property to it (as in the Singleton pattern):
class frmMain
{
private static frmMain current;
public static frmMain Current
{
get
{
return current;
}
}
public frmMain()
{
current = this;
}
}
Then you can use this property to construct your MDI-child forms:
childForm.MDIParent = frmMain.Current;
|
|
|
|
|
Thank you Andrew, very much. It works like a clock.
I've tried something similar, but mine wouldn't work .
I've used other class for this, and it happened nothing, no error, no action, no anything .
And again, thanks.
|
|
|
|
|
i'm writing simple application that uses TCPListener and Client - i use BackgroundWorker to make listening in other thread. It set, when any error ocured function will use ReportProgress function and it will cause event and event will notice window etc ;]. My question is - i'm trying without debugging (just run exe) it work fine, with no problems - but WHY when i'm doing this same operation WITH debugging i get exception i can't access component in thread control weren't created in. I chceked - debugger show this line of code is called in BackgroundWorker thread - but how it work in "normal" mode?
Ideal compilator compiling comments without code...
|
|
|
|