|
Hi,
your 3 lines of StreamWriter code work fine inside one of my PrintPage methods.
some possibilities:
- your file already exists and is read-only or locked by another process
- you ar looking at the wrong file (using a relative path, and current directory maybe changed)
- you are getting an exception but missed it somehow
Luc Pattyn
|
|
|
|
|
Thank you all, It was putting in a wrong folder. so i just have the absolute path now.
This leads to my next question which is if i try to write in a file then there is no data in a file but if comment the loop then there is something.
I want to write in a file until i<5. is there something i am not doing right.
for(int i=0;i<5;i++)
{
sw = new StreamWriter(@"C:\myfolder\path.txt");
sw.writeLine(i.ToString());
sw.flush();
}
sw.close;
Thanks
|
|
|
|
|
Hello,
I'm not sure if it's usefull to create a new instance of StreamWriter (in youre case 5) inside the for loop.
If yes, you would have to call the close method also in the loop, otherwise only the last StreamWriter instance would be closed (disposed).
If not, you should do this:
sw = new StreamWriter(@"C:\myfolder\path.txt");
for(int i=0;i<5;i++)
{
sw.WriteLine(i.ToString());
sw.Flush();
}
sw.Close();
All the best
Martin
|
|
|
|
|
Yes, you should create only one streamwriter, then have the loop, or whatever makes
up the file's content, then sw.Close().
And sw.Flush() is not doing anything useful here.
It is useful only when the content generation takes a long time, so you
want to force the sw to already send to file what it currently contains; it is
impled by a sw.Close(): when closing the sw, everything it still holds is flushed,
i.e. sent to the file.
If you are used to C (or some similar language), you can compare the StreamWriter you
are using to a regular file with functions fopen, fwrite, fclose (and optionally fflush).
Luc Pattyn
|
|
|
|
|
What is the correct value for SW_SHOWNOACTIVATE in ShowWindow function? Is it 0x0700 or 12? Do I have to give in hexadecimal or decimal?
Can anyone please help me find this?
Muthu.
|
|
|
|
|
File C:\...\VC98\Include\WINUSER.H Line 257: #define SW_SHOWNOACTIVATE 4
Luc Pattyn
|
|
|
|
|
I am sorry. I am using C#, Framework 1.1
Thanks.
Muthu.
|
|
|
|
|
The symbol SW_SHOWNOACTIVATE does not look at all like a C# name, it really is part
of the good old Win32 API specifications.
Whatever you do at a high level, in whatever language, in the end the UI stuff gets
handled deep down in Windows so when you do some magic that is supposed to understand
SW_SHOWNOACTIVATE, just pass it the value of 4.
Luc Pattyn
|
|
|
|
|
I believe that it is actually 4, and it doesn't matter whether or not it is hex.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello,
Can anyone please help me to write code (language: any .Net platform) to append text to a WAV file?
I know the basic file I/O all I need is to know how to write proper header information in the WAV file along with proper byte count which includes the actual WAV file and newly appended text at the end.
Found this link: http://www.codeproject.com/useritems/Concatenation_Wave_Files.asp
But in this example the program amalgamates 2 WAV files as in my case its 1 WAV file + 1 text file = 1 WAV file with all information in it.
Thank you in anticipation.
Regards,
Amit
-- modified at 9:17 Monday 15th January, 2007
|
|
|
|
|
Hi all,
I am developing an window application using c#.net. I want to deploye the project.While deploying the project i have some doubts that is, While installing the the product the Framework should be checked and to be installed also the MSDE, and a windows service.
Also if the setup has to check for the update. I want to create this using the .NET default Deployment Wizard, can any one suggest me how to do this with an example or any tutorials for this??
I am having an major doubt that is it possible to install Framework, MSDC and the Product in Mac and Linx OS.
Thanks in advance
Know is Drop, Unknown is Ocean
|
|
|
|
|
Exelioindia wrote: I am having an major doubt that is it possible to install Framework, MSDC and the Product in Mac and Linx OS.
With good reason. .Net is not compatible with MAC and Linux. There is a port (Mono), but not all .Net functionality is supported by Mono. MSDE is not supported on Mac/Linux. You will need a different database for those.
|
|
|
|
|
First, try using a better title then Hi..... How to get an answer to your question
If you use the default setup project for .net it will do the check and install the appropriate framework for you. Also, you want to use SQL Express which is the replacement to MSDE.
See the section "Investigating Installers" here for a short discussion of installing a service
http://msdn.microsoft.com/msdnmag/issues/01/12/NETServ/[^]
Exelioindia wrote: I am having an major doubt that is it possible to install Framework, MSDC and the Product in Mac and Linx OS.
You're right. Mac, why would you want to anyway. Linux you would need to make use Mono
only two letters away from being an asset
|
|
|
|
|
Hello,
I have my VS2003 Project under Subversion control and wanted to find out (per code) which revision number has my project.
I tried:
NSvn.Core.Revision rev = NSvn.Core.Revision.Head;
NSvn.Core.ClientConfig clientcfg = new ClientConfig();
NSvn.Core.Client client = new Client(mypath);
I also looked into:
NSvn.Common
No luck so far (also google hasn't helped me this time.)
Thanks for your time and help!
All the best,
Martin
-- modified at 9:44 Tuesday 9th January, 2007
|
|
|
|
|
Here's how to get the BASE revision (the revision a working copy contains) - I use this to generate the version number for the AssemblyInfo file in the pre-build-task:
Client client = new Client();
int revision = client.SingleStatus(workingDirectory).Entry.Revision;
This operation does not contact the server, it simply looks at the .svn folder.
Getting the HEAD revision might work similar (but you have to contact the repository), try to get the status of the repository URL.
|
|
|
|
|
Hallo Daniel,
Thank you very much for your answer!
I think this is exactly what I needed!
I will test it soon.
Thanks again!
All the best,
Martin
|
|
|
|
|
Hallo Daniel,
Just tested your code sample, and I'm happy now.
Thanks again!
Martin
|
|
|
|
|
Hi,
I hadn't used data breakpoint before, but it seems it's going to come in handy. If I can actually get it to work, that is.
I'm trying to set a data breakpoint for an integer value, but can't since the option (debug -> new breakpoint -> data breakpoint) is always disabled: Either before starting the program or while stepping during runtime, it won't enable. I'm using VS2005 Pro, so I'd think it should work. Any ideas?
Standards are great! Everybody should have one!
|
|
|
|
|
Data Breakpoints can only be set in C++ Native code:
How to: Set a Data Breakpoint (Native Only)
http://msdn2.microsoft.com/en-us/library/350dyxd0.aspx[^]
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Thanks, that really sucks. I think I'll do a feature request for that...
Standards are great! Everybody should have one!
|
|
|
|
|
Hi All,
I have a case that i need to browse through the directories and files of a unix server through C#.NET or VB.NET Code. Can anyone help me out???
Exact scenario of the problem is:
i need to ftp a file to unix server from windows machine through VB.NET Code. But Before that i need the check the unix server whether the file already exist or not in a particular directory of the unix server. If the file already exist in the unix server, i have to wait until the file to be removed in the unix server and then ftp the file to unix server.
gokulnath
|
|
|
|
|
If you know how to programmatically FTP-PUT a file, couldnt you first try an FTP-GET
to see if it already exists ?
Luc Pattyn
|
|
|
|
|
I need help... I have two datagrids, one is binded to a Datatable and one is binded to a Dataset. The problem is, keydown events are not recognized on the Datatable side while on the Dataset they work. Thanks in advance. 
|
|
|
|
|
Hello
I have a question about working with COM objetcs made in C#. Creating the objetcs is not a problem, my question is how to work with config files. How do I get information from an config file so that I can read it with my COM object?
My situation right now is that I have a .Net object that most of the time will be accessed by a .Net application, but somtimes by an application written in VB6 (or any language supporting COM). In the config file for the .Net application I have some parameters that I want to read, not just in the appSettings section but also for example configSections and system.diagnoostics section.
I hope that Microsoft has thought of that when they made .Net support COM, but I dont know how they did it if they did it. Antoher solution is to always try to read the config file with ConfigurationManager.OpenExeConfiguration(FilePath) but then I cant read some sections properly without resorting to converting them into a XMLDocument:
<code
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(FilePath);
ConfigurationSection confsec = config.Sections["system.diagnostics"];
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(confsec.SectionInformation.GetRawXml());
System.Xml.XmlNode node = doc.SelectSingleNode("system.diagnostics/switches/add[@name='Trace']");
if (node != null)
{
System.Xml.XmlAttributeCollection attribs = node.Attributes;
TraceSwitch generalSwitch = new TraceSwitch("Trace", "Controls the Trace Level");
generalSwitch.Level = (TraceLevel)Convert.ToInt32(attribs.GetNamedItem("value").InnerText);
}
</code>
Or should I abandon config files and use INI files instead?
Is there a way in an .Net object to see if the object is started by an application using COM or if it is an .Net application?
I hope the question(s) are reasonably clear and that someone could enlighten me in the way of using config files when the calling application is an COM application written in VB6.
Sorry for my bad english.
Best regards
/Marcus
|
|
|
|
|
hi,
how to retrieve string as well as int from single function
with regards
|
|
|
|