|
Well, you'll have to set up two streams. One to read the file, and one to write to the other.
So simply:
byte buffer = new byte[5335040];
FileStream read = ...;
FileStream write = ...;
int bytesRead = 0;
while(not at end of file)
{
bytesRead = read.Read(buffer, 5335040);
write.Write(buffer, bytesRead);
}
I might have the parameters on the methods a little wrong, but you get the idea right?
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
|
Hi,
I have a datagrid view bound to a List of objects implementing INotifyPropertyChanged. One of the object's properties is an enumeration, which I want to bind to a DataGridViewComboBoxColumn so that the user can change it's value.
The problem is that if I bind it to the enumeration property, it will only show the enumeration value it's initialized at. I've found many examples stating you should set the combobox's DataSource property to <code>Enum.GetValues(typeof(EnumerationType));</code> This shows all values in the combobox, but I don't see the point: It won't bind its values to my actual data source.
Example:
<pre>
public class Dinges : INotifyPropertyChanged
{
public enum tester
{
apple = 1, pear = 2, banana = 3
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
private tester enumerationtest = tester.apple;
public tester MyProperty
{
get { return enumerationtest; }
set
{
enumerationtest = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("MyProperty"));
}
}
}
public class DingesList : List<Dinges>
{
public DingesList()
{
this.Add(new Dinges());
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
DingesList d = new DingesList();
dingesListBindingSource.DataSource = d;
dataGridView1.DataSource = dingesListBindingSource;
// this results in the combobox in my datagrid showing "apple" as a value and no other options to choose from
// option 2 displays all possible values, but isn't bound to the actual object
comboColumn.DataSource = Enum.GetValues(typeof(WindowsApplication1.Dinges.tester));
}
}
</pre>
Any help is greatly appreciated.
Standards are great! Everybody should have one!
|
|
|
|
|
Hi,
I want to publish my application as it will be deployed on number of systems. But the problem is..configuration file of each system should be set according to its department. It means that department will be able to access only concerned section of the application. I want to configure this application configuration file. Now if i publish it..i am not getting configuration file in each system. How can i set configuration file for each system?
Thanks in advance
|
|
|
|
|
Hi,
I have added an outlook addin project.Everything works fine.
Whenever I receive a mail an Incoming mail event needs to be fired and hence I do my processing further.
This works fine when the outlook is opened.But when my outlook is closed and if I receive the mails in the mean time, again when I open the outlook the "Incoming mail event" is not fired for all the new mail messages. What could be the problem?
How Should I handle this ?
Any Suggestions would be helpful.
Thanks
Satya
Today is a gift, that's why it is called the present.
|
|
|
|
|
It sounds like your event's being hooked after the initial load (loading of new messages into the inbox folder). Once it's hooked, any new messages are handled properly.
I'm not familiar with this, though. Maybe you can try and change the outlook settings so new messages aren't downloaded until you manually check them? (maybe that would give time for you hook to be in place?). Ideally the hook should happen before the download event.
|
|
|
|
|
Hi,
When I pass Strings as arguments to delegate, it runs perfectly fine.. But when I try to pass String Arrays, it gives error..
So does that mean we cant pass string arrays as parameters to delegates???
Here's a snippet of code:
public: delegate void myDelegate1(String^);<br />
<br />
public: delegate void myDelegate2(array<String^>^);<br />
<br />
<br />
<br />
private: void BasicPolicyMethod()<br />
<br />
{<br />
<br />
String^ str = "Hi";<br />
<br />
array<String^>^ arrstr = gcnew array<String^> {"Hi","Hello"};<br />
<br />
<br />
<br />
this->Invoke(gcnew myDelegate1(this, &DashBoardForm::myMethod1), str);<br />
<br />
<br />
<br />
<br />
<br />
this->Invoke(gcnew myDelegate2(this, &DashBoardForm::myMethod2), arrstr);<br />
<br />
<br />
<br />
private: void myMethod1(String^ str)<br />
<br />
{<br />
<br />
<br />
<br />
}<br />
<br />
<br />
<br />
private: void myMethod2(array<String^>^ arrstr)<br />
<br />
{<br />
<br />
<br />
<br />
<br />
}<br />
<br />
<br />
<br />
Any replies would be appreciated..
Thank you !!
|
|
|
|
|
What language is this? Some bestiality between MS and C++? This is the C# forum.
Cheers,
Vikram.
The hands that help are holier than the lips that pray.
|
|
|
|
|
I think thats ye olde C++ using the .NET framework. I can't be certain though.
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
SK Genius wrote: think thats ye olde C++ using the .NET framework. I can't be certain though.
This is the latest C++/CLI langauge implemented both in Visual Studio 2005 and just released 2008..
Only the syntax is a bit different..
I dont think one would have many problems if he knows C#..
How can we pass String arrays as parameters to Delegates in C#??
If anybody knows please help me with a sample thread..
Or the moderators may please move this thread to the appropriate forum..
Sorry for posting in the wrong forum..
|
|
|
|
|
Hi all,
I am having a form and in that a tab control is loaded.
On clicking of a button in that form a sub form has to be loaded as dialog box. When the "Ok" button is pressed in the sub form, it has to be closed.
When I tried with the above, the sub form is opening and when the manipulations were completed and the "Ok" button is clicked, it closes the main form.
Can any one faced this problem?
It would be a great help if you can suggest me a way to get rid of this problem.
Thanks a lot in advance.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
It would be helpful if you can show your code.
|
|
|
|
|
|
Hi there,
I'm writing an application that will do some logging to a flat file, particularly I want to append log entries to an XML file. In order to do this, I seek advice for an appropriate design for this to work.
Say I have a class that defines the types of information I want to store for instance,
// Very briefly
public class LogEntry
{
private string workstationName;
private string message;
public string WorkstationName
{
get { return workstationName; }
set { workstationName = value; }
}
public string Message
{
get { return message; }
set { message = value; }
}
public LogEntry()
{
}
}
If I want to make log entries like these, and append them to an XML file, how would I go about achieving this efficiently. Now I know I can't really use XmlDocument since it's the DOM way, it caches the entire schema in memory. I want to implement in a way that it keeps appending to the XML file without actually caching in memory, and will be closed at the end of the application. If I were told to use XmlWriter or XmlTextWriter, it seems like a chore to write the the start and closing tags for each value I write. Is there an easier way to do this? Also I don't really want to use Logging frameworks like log4net. I think it's overkill for what I want to do. XML flat file is fine but I want to implement it properly.
Please advise, thanks.
|
|
|
|
|
Zerox MXI wrote: If I were told to use XmlWriter or XmlTextWriter, it seems like a chore to write the the start and closing tags for each value I write
You can't avoid this as XML files needs tags. Also I don't think that XML files are not a good idea for logging, I am not sure on this. What is the problem of using simple text files ?
|
|
|
|
|
I just want a more portable format in comparison to a text file. Well, if large scale logging or speed is a requirement then it's obvious flat file logging will lose out. I just wanted simple, but I want the format of the log files be XML so I can use it in any way possible in the near future. Probably things like translating them into other formats like HTML, text using XSLT and stuffs.
I think it's really a nice format for a variety of uses as compared to a text file.
Yes I know what is an XML file and it has tags in them, but I want appending of data to be more transparent. Say AddLogEntry("Something"), and it'll append nicely into the XML file. I would like to do it from the class approach, rather than reading the data from the object and then writing it to the XML by specifying the open and close tags all the time.
|
|
|
|
|
XMLTextWriter class can't append nodes to XML file. You have to use XMLDocument class, add a new node and call it's Save() method. But XMLDocument class loads the whole XML file initially. This can be a performance issue.
I suggest you to write to plain text file. Each log entry will be appended as a new line to the file. When you need to generate reports, create a XML file by reading this text file data. I guess this method will be efficient.
|
|
|
|
|
I suggest you seriously look at fixed width files. Have a look at Log4Net or some such logging framework.
Cheers,
Vikram.
The hands that help are holier than the lips that pray.
|
|
|
|
|
Why reinvent the wheel. Look at the Enterprise Library Logging Application block
only two letters away from being an asset
|
|
|
|
|
All,
I have a requirement for accessing the information that you get when you right-click on an executable and select 'properties'. 'CompanyName', 'Version' etc.
Anyone have any idea how this can be achieved in C#? I have searched but can find nothing.
Thanks,
Darin
|
|
|
|
|
|
we all know that there is an Open source Cross platform like of the Microsoft .NET development platform called MONO.... i have opened this Board for discussing whatever we are thinking about mono. The purpose is to clarify what is possible and what is dream.
I'm not an expert in either Microsoft .Net nor MONO (Unix .Net if i can say). I'm looking to be an expert in one of these since i have Linux and Windows knowledge. but i have limited time for both, so i need to dedicate my time for one at the same time I'm a supporter to the Open Source idea of MONO...
please have a look at http://www.mono-project.com and then add your questions and comments.
B.R
Ahmad Zuhd
modified on Monday, April 28, 2008 4:01 AM
|
|
|
|
|
Please don't use bold for the whole post.
|
|
|
|
|
We talk about C# in this forum. If it happens to work under Mono, that's fine, be we don't talk specifically about it because, well, this is a Windows programming site.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I've used Mono and am familiar with it, but this is a question/answer forum.
Mono is a follower, not a leader. So if you're going to dedicate your time I would suggest .Net and then incorporate that into what you'd like to learn about Mono later.
|
|
|
|