|
Something like this:
string base64;
<p>
using (FileStream fs = new FileStream(@"c:\whatever.doc", FileMode.Open, FileAccess.Read))
{
byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
base64 = Convert.ToBase64String(data);
}
</p>
You then get your word document as a huge base 64 string which you can save/stream/whatever..
Regards,
Rob Philpott.
|
|
|
|
|
Thank you verry mutch for your answer, so how we can do the conversly of this aoperation, we get a word file from a code 64 digits, thank you verry mutch.
|
|
|
|
|
Try this (after the last code block):
byte[] data2 = Convert.FromBase64String(base64);
<p>
using (FileStream fs = new FileStream(@"c:\whatever2.doc", FileMode.Create, FileAccess.Write))
{
fs.Write(data2, 0, data2.Length);
}</p>
Regards,
Rob Philpott.
|
|
|
|
|
Thank you verry mutch, we can generate doc file from a fonction??
i use this fonction :
public void DecodeFileTo64Digits(string txtinput)<br />
{<br />
byte[] data2 = Convert.FromBase64String(txtinput);<br />
using (FileStream fs = new FileStream(@"C:\Documents and Settings\Administrateur\Bureau\Doc.doc", FileMode.Create, FileAccess.Write))<br />
{<br />
fs.Write(data2, 0, data2.Length);<br />
}<br />
<br />
}
but this fonction generate a doc file automaticly, i would to do this :
public docfile DecodeFileTo64Digits(string txtinput), witch i cutch a doc file with another fonction.
Thank you verry mutch.
modified on Wednesday, February 11, 2009 4:59 AM
|
|
|
|
|
Convert.FromBase64String covert a word file to base 64 digits, we can convert another file like txt and pdf?? thank you verry mutch.
|
|
|
|
|
Can we detect a change on a form without comparing value of each control with previous value or by checking individually the text change or value change for each control on form in winforms
Thanks in advance.
|
|
|
|
|
|
Without writing your own custom solution, no. There's no "something changed somewhere" event.
|
|
|
|
|
I has cursor in dropdown.
I need that when I click on form it and than scroll than it should scroll the form but dropdown doesn't lose focus and on scrolling it scrolls items inside dropdown
Thanks in advance
|
|
|
|
|
Uhhh...What?? I don't think there's a single person here who could understand what you just said...
|
|
|
|
|
LMAO, im suddenly worried that i have forgotten how to understand my national language
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
Try setting the focus to other controls either in combobox leave event or form click event.
|
|
|
|
|
i have installed enterprise application block first and then i am trying to install updater application block but it always try to locate enterprise library component. so please tell me which component i have to mapped. i saw it is looking for one .sln fine. please guide me in detail to install updater application block.
Thanks
tbhattacharjee
|
|
|
|
|
Hy everyone!
I do need your help. I would like to create a logfile for my application one a day (eg. Logfile_20090210.log for today, Logfile_20090211.log for tomorrow etc.).
the log4net config file looks like this
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="C:\\PrintService.log" />
<param name="AppendToFile" value="true" />
<param name="rollingStyle" value="Date" />
<param name="datePattern" value="yyyyMMdd" />
<layout type="log4net.Layout.PatternLayout">
<!-- <param name="Header" value="[Header]\r\n" />
<param name="Footer" value="[Footer]\r\n" /> -->
<param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
</layout>
</appender>
<root>
<!-- <level value="INFO" /> -->
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
</configuration>
I do have two problems:
there is no logfile with the config above. when I change this to "yyyyMMdd-HHmm" for datePattern, then it works, but I do not want the time to be part of the logfilename.
the second problem is the logfile is named PrintServce.log20090210-1346 for example.
So my question:
What does the config have to look like to get PrintServer_20090210.log for example?
I found pages with configs similar like mine ("yyyyMMdd" for datePattern). But none worked!
Thanks for any help!
Stephan.
|
|
|
|
|
hi,
someone has an idea for object the i can write to it strings (with the first thread) and read from this object at th same time(with the second thread)?
it will be very helful if this object will can convert itself to StreamReader.
thank you.
|
|
|
|
|
why would you need to do that?
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
now, i can analize a file (file.log) convert it to StreamReader and analize it with my object Parser(StreamReader sr).
(i am using there sr.readline() etc.)
now i want to receive the same information from port.
i want to receive information from port232 (strings) and to save them (somewhere),and to analize them with th same object Parser(StreamReader sr) on a real time(2 threads- one for writing information from port to StreamReader(possible???) and another thread for reading the inforamtion by using Parser).
thank you.
|
|
|
|
|
ok well i think the problem you will have is writing to a file that is open for reading.
So you could either close the file after the write and then read, somehow you will have to decide which process to do, or alteratively you could pass the string value to the parsing thread and write it to the log file, rather than reading from the file.
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
i thought about it but..
opening and closing the file a lot of times will not slow down the analizing time?
maybe there is something like "virtual file" or another solution that will let update the real file every X seconds?(for backup).
or this is the only way to solve this problem?
|
|
|
|
|
i think you should be opening and closing streams with each write anyway, you dont want to leave a stream open longer than needed.
As i also suggested, i think the best way is to:
Get string from port,
Write it to the log file,
then pass it to the parsing thread for whatever that needs to do
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
I have a solution with various projects, normally I gather the logon credentials via the UI and settings and pass 1 copy to the DAL. In this project there will be multiple DAL implementations all requiring a set of credentials. Credentials is declared as a class in the intermediate layer (server,DB,User & password) which is referenced by the UI.
Now I have the requirement of passing the creds to many objects which do not reference where the Credentials class resides. I initially created a copy of the Credentials class in the target object and attempted to pass Credentials as an object and then converting to the local Credentials type.
DAL.Server = (Creds as Credentials).Server;
This gets an error to use NEW. Creds is an object and has data in it.
Any recommendations on how to do this properly
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
you should use interfaces. Define a Credentials-interface, which will be accessible by all objects (do this by putting the interface into a seperate assembly). Let your Credentials-class implement the interface. Within all objects you can now use the interface to interact with the object, without knowing how it is implemented (how it should be within OOP).
interface ICredentials {
}
Your credentials-class:
class Credentials:ICredentials {
}
How to use it:
DAL.Server = MyCreds.Server
Hope this helps.
Regards
Sebastian
|
|
|
|
|
There you go, ask for a simple casting solution get the application of a whole different technology. What a way to learn, I have not used interfaces except when building services, will be working with this info today.
Thanks
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
It turns out the interface does not meet the requirements - one of the assemblies will need to be isolated for use with another solution and will not have access to the interface. Changed it to use a list<string>.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i developed an application for a mobile device using ce 5.in the application i have two forms A ,and B. A is the main form and B is the child form most of the times form B is created, used and closed.but before showing the Form B the memory
usage (ex: 15MB) when form B is loaded the mem is (ex:16MB),but when the form is closed the mem is still 16 MB.i there might be a memory leak . do you
have any suggestions on this
|
|
|
|