|
Yes, of corse this code d'ont work, i would axplain idea, when i do : s2.save_repport("","",true); , i find an empty file, i dont find this text : rapport1, thank you verry mutch?
|
|
|
|
|
Well, it should just work.
Maybe you are using the wrong type. Try it like this:
TextWriter fichier = new StreamWriter(path + "\\" + Now.Year.ToString() + "\\" + Now.Month.ToString() + "\\" + Now.Day.ToString() + "\\" + heure + "\\" + name_of_file+".txt");
fichier .WriteLine(ee.ToString());
fichier .Close();
I also don't understand why you use a string and put a boolean as string in there, you could just do it like this: boolean state. And then if(state)
And for the path try using the stringbuilder or string.Format, like this:
<br />
new StreamWriter(String.Format("{0}\\{1}\\{2}\\{3}\\{4}\\{5}.txt", Now.Year.ToString(), Now.Month.ToString(), Now.Day.ToString(), heure, name_of_file));
|
|
|
|
|
Tbl.Add(rapport);
Where is the rapport in the code ? I think you misspelled the variable name.
you should use
Tbl.Add(repport);
also why you are storing the string in array list and then writing the arraylist to file. its just a string right so you can use,
Fichier.Write(repport);
and no need to use arraylist.
instead of this
foreach (object ee in Tbl)
{ Fichier.WriteLine(ee); }
Also I will suggest you not to use "save" as a class name. you might get confused with "Save()" method sometimes. its always good, not to use inbuilt variable/function name, keywords in User Defined Variable / Method.
|
|
|
|
|
rapport was a string, i would write the repports on the file txt on ther differents methodes. thank you
|
|
|
|
|
hi,
i am looking for code for a localization control(component in form of dll) which reads and displays the local settings of the machine.
|
|
|
|
|
I have a couple of questions first. Is it better to use VARBINARY or text when saving and getting files from a database? This is the code I have, and it works fine, but remotely it is slow and I think this is why:
int bytesSize = 0;
byte[] downBuffer = new byte[255];
byte[] buffer = (byte[])cmd.ExecuteScalar();
conn.Close();
MemoryStream ms = new MemoryStream(buffer);
FileStream fs = new FileStream(Path, FileMode.Create, FileAccess.ReadWrite);
while ((bytesSize = ms.Read(downBuffer, 0, downBuffer.Length)) > 0)
{
fs.Write(downBuffer, 0, bytesSize);
WriteTextBox((fs.Length / 1024) + "KB of " + (ms.Length / 1024) + "KB.");
bw.ReportProgress(Convert.ToInt32((fs.Length * 100) / ms.Length));
}
Now remotely this is where it pauses:
byte[] buffer = (byte[])cmd.ExecuteScalar();
Is this because technically that right there is downloading the file? Is there a way to actually download the file byte by byte so remotely it doesn't pause right there and this can continue to report progress (Backgroundworker)? It also times out remotely as well because its taking too long to execute that statement
|
|
|
|
|
Pauses? How long?
What's in the field? How big is it?
I've stored files in a database and not had any problems (I have forgotten what type of field I used, possibly image).
And when I wrote one back out I used:
filestream.Write
(
bytearray
,
0
,
bytearray.Length
) ;
It all seemed quick enough, even for several megabytes.
|
|
|
|
|
The file that I tested it on was 16MB. Now I was VPN so it was going through that. I set the timeout for 60 seconds, so it was taking longer than 60 seconds for that command.
|
|
|
|
|
here is a code snip i am using but when i save a jpg with this code it is 24 bit grayscale
saveJpeg(file1,img,8);
private void saveJpeg(string path, Bitmap img, long quality)
{
// Encoder parameter for image quality
EncoderParameter qualityParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);
// Jpeg image codec
ImageCodecInfo jpegCodec = this.getEncoderInfo("image/jpeg");
if (jpegCodec == null)
return;
EncoderParameters encoderParams = new EncoderParameters(1);
encoderParams.Param[0] = qualityParam;
img.Save(path, jpegCodec, encoderParams);
}
private ImageCodecInfo getEncoderInfo(string mimeType)
{
// Get image codecs for all image formats
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
// Find the correct image codec
for (int i = 0; i < codecs.Length; i++)
if (codecs[i].MimeType == mimeType)
return codecs[i];
return null;
}
Thanks,
Chad Aiena
|
|
|
|
|
Lol I think this piece of code is funny:
for (int i = 0; i < codecs.Length; i++)
if (codecs[i].MimeType == mimeType)
return codecs[i];
return null;
}
You can better rewrite it like this:
if(codecs.Length >= 1)
{
if(codecs[0].MimeType == mimeType)
return codecs[0];
return null;
}
But what is your question exactly?
|
|
|
|
|
I had one application in c# asp.net 1.1.There form id is come in html page.Now i converted to 2.0 and put it into master page ange inheriting another page which has contain place holder.how i will use tha form id there . because in 1.1 the form id is used in a java function. in 2.0 in the function it is there the form id name is there but in codebehind form id is not declared. how to use form id in 2.0
|
|
|
|
|
this[^] may help
BTW when you post message nextime, use these subjects
hi, I'm sachin tendulkar
how are you ?
show me what you've got ?
or any appropriate subject belongs to your question or problem
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
First of all, this is the C# forum, for ASP.NET questions, we have an ASP.NET forum, try your question there.
Second: if you have a question, you should use the question mark to show which sentence is your question. That would be a lot easier.
|
|
|
|
|
Hi
I had a BHO through which I had to convert the web page content from English to other language (say Hindi). I am able to retrieve the web page content and replace it with other language text, but the problem is the original text visible to user for a fraction of second (which is < 1sec), I want the converted page should be directly visible to user. For this what can I do?
I had trying for this since longtime?
If there are any advises, please post it here, thanks...
|
|
|
|
|
Hello. I am new to C# (used Java originally), and I was wondering what would be the best way to handle file events in a console application. Specifically, I need to monitor a bunch of directories to see if new files are being added, and then do something with them if so. I guess I'm confused because I need to thread the watchers, but am unsure how/where to handle their corresponding events. I have been looking around for resources but am coming up on threading samples and event samples but not any combination of the two and so I don't know exactly where to start. If anybody has a suggestion or resource, I would greatly appreciate it!!
|
|
|
|
|
start by reading about "System.IO.FileSystemWatcher".
|
|
|
|
|
Thank you, that helped clarify some of the event concepts for me.
I guess I'm wondering now whether the filesystemwatcher acts as a thread... meaning does it listen indefinitely while the main program works until it hears something? Or does it have to be wrapped in a thread to do so?
|
|
|
|
|
I believe it works on its own thread, then invokes the events to the UI thread. If your GUI is going to stay responsive, you don't have to worry about threading at all. Just create it, set the needed properties (Path, NotifyFilter, Filter), turn on EnableRaisingEvents, hook the events you want, and handle them as needed. If I remember right, this is a port from the old VBScript library, so it's intended to be as easy to use as possible.
To make sure it works that way, you might want to just be sure that you're CREATING it on the UI thread. If you don't, it might invoke events to a different thread unless you set the SynchronizingObject property to a GUI control. You can also use that same property to invoke the events onto a thread of your choosing.
If you want finer control, you can skip the events entirely, create it on a dedicated background thread, and loop on the WaitForChanged method, which will block until it receives a notification. Most of the time, this is overkill.
There's more detail on each of those properties and methods in the MSDN help.
EDIT: Sorry, missed where you said it was a console application. In that case, you probably want to go with the last method I mentioned, looping on WaitForChanged to do everything synchronously.
modified on Wednesday, March 25, 2009 11:10 AM
|
|
|
|
|
hello.. i have an msaccess database in my c# project given the path as c:\my proj\db.mdb
and in my second project i reffered to the same database and when i change the db.mdb from its original location the visutal studio cant find the db and giving an error.... is if possible to change the path of the database after adding to the project...thanks...
|
|
|
|
|
Thats what app.config is for.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
thanks... that was xtremly helpful...
|
|
|
|
|
Do I detect a hint of sarcasm here?
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
sorry if u have fealt like that but ur answer solved my problem.. cause i had googled it with long strings but colud not find any relavant answers....
|
|
|
|
|
No offence intended, its just that often if you just give someone a hint they can't be bothered to follow it up, they expect complete code samples. I'm pleased it helped, I generally only give an idea of the answer, as by finding out for yourself you learn. Obviously in your case it applied
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hi all!
I have a small project where I need to create a visual family tree editor. Before I start reinventing the wheel, I would like to know if there are any free or open source C# library which lets me do the following:
-add, select and remove elements (simple boxes with title is enough) with mouse and context menu
-connect and disconnect elements with mouse.
If I have this, I 'll be able to do the rest myself (attaching some data structure to the visual tree and storing the tree to a database).
Thanks for any ideas.
|
|
|
|