|
Visual FoxPro
Everything makes sense in someone's mind
|
|
|
|
|
Hi
I know this is a simple and silly question to some of you out there, but can someone show me how it is possible to write binary data to a memory stream rather than to write the binary data to either a dat file or to pdf file? You see, I don't want to write or save any data to a file.
|
|
|
|
|
AndyASPVB wrote: I know this is a simple and silly question to some of you out there
yes, it is. And that is linked to the fact that we occasionally read the documentation.
File.Create returns a FileStream, which offers methods such as Write and WriteByte.
MemoryStream is a class with similar functionality, offering methods such as Write and WriteByte.
And that is no surprise, they both inherit from Stream, which ... offers Write and WriteByte.
Also, lots of classes (e.g. Image) can Save to a stream, and don't care whether it is a FileStream, a MemoryStream, or yet some other kind of stream.
So what could possibly be your problem?
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
I am not that familiar with Memory Stream and Binary Reader and Writer, and thus just need an example to go by. Do you have an example to go by?
|
|
|
|
|
your original post suggested you were familiar with writing binary data to a file.
then you down-voted me, and now you ask about binary reader and writer, which I did not mention, and you ask for examples, of which MSDN, CodeProject and Google are full.
I suggest you now start reading some documentation, while I'm off for lunch.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
Luc Pattyn wrote: while I'm off for lunch
I didn't know lunch was at night in Belgium
|
|
|
|
|
It isn't in general, but I'm running a bit late. Anyway, it's still too early for supper, and I'm hungry, so it is bound to be lunchtime now.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
harold aptroot wrote: I didn't know lunch was at night in Belgium
Frites, Genever, who cares what the time is
|
|
|
|
|
Hi everybody,
I need to locate on a specific DataGridView row without filtering the grid.
I don't want to use DataGridView.CurrentCell Property Too. Because by using this, I have to check the grid from the first row to the end.
Can any body help me?
Thanks a lot.
|
|
|
|
|
If you use a BindingSource to connect your DataGridView to the data check the documentation for BindingSource.Find
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I put a message on this board a couple of hours ago, but I can't see it so I think I might have been bumped. anyway, I'll try again.
I'm a very experienced (20Yrs +) VB developer, and have used classes and collections so much that I raise them without thinking of how I do them. now I'm trying to transfer to C# I'm trying to find a way of doing the same thing. I have an inventory table consisting of the following fields:
ID - int
SKU - string
Description - string
Unit - string
QtyOnSite - double
ValOnSite - double
I can raise an inventory class, but now i want to read all the information from a sqlserver table into a collection of type inventory. Could any of you wizards give me a clue as to how to do this please?
Chiefy
|
|
|
|
|
How would you do it in VB? Open a connection to the database, execute a command, iterate through the results, instantiate a class, add to a collection
List<MyClass> myClasses = new List<MyClass>();
IDataReader dr = cmd.ExecuteReader();
while(dr.Read())
{
MyClass cls = new MyClas();
cls.ID = dr.GetInt(0);
...
myClasses.Add(myClass);
}
only two letters away from being an asset
|
|
|
|
|
it looks really easy like that. I'll give it a try when I get back to work. In VB6 I would raise a class 'Inventory' containing all the fields I've already mentioned. The class manager would then apply all the 'get and 'set' attributes to the class members (I'm probably not using the right descriptions here). I would then raise a collection of class Inventory. I then would connect to my database, return a recordset of Inventory, and iterate through it, adding the information into the fields of the collection:
do until recordset.eof = true
inventory collection .add (the columns of the inventory table)
loop
Thanks for you help
C# is great....
|
|
|
|
|
It will work pretty much the same way in C#, the code only changes slightly. You should have specified you meant VB6, I think the other reply assumed you were going from VB.NET to C#, because VB6 has been obsolete for almost a decade.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks Christian, I'm going to try it now. sorry about the misunderstanding about VB6, I tend to think in that language. I know it's been obsolete for a long time, but there is still lots of VB6 code out there. I've not forgiven Uncle Billy for ditching it like that, although I can understand why.
Chiefy
|
|
|
|
|
I am reading an Excel file into a dataset, then later into an Access table. All being done using C#. The first thing I do is load a dataset with the Excel data. There is a column in the Excel file called SEQNUM, and the corresponding Access column's name is the same. It's a DateTime field. The data in the Excel file appears to be a datetime.
When I look at the dataset with the DataSet Viewer, the data in the SEQNUM column looks like this:
-7017917/858993439/08
-7017918/858993451/08
3/-29/34
3/-28/34
1/-429496757/35
-20/-429496747/37
-20/-429496746/37
-13/-429496759/37
-13/-429496758/37
2/-429496749/36
2/-429496748/36
2/-429496747/36
-15/-429496758/38
-15/-429496757/38
0/-429496748/37
0/-429496747/37
.
.
.
When I show formulas in the Excel file the data looks like this:
35225781579640
35225781730541
35225781947742
35238693176684
35241364002568
35241364163669
35241364316770
These number appear to be too large to be an Excel date. Anyone know what this is? Is the conversion to a dataset screwing up the data?
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
Kevin Marois wrote: These number appear to be too large to be an Excel date. Anyone know what this is? Is the conversion to a dataset screwing up the data?
Dates in Excel are stored as real numbers where the integer portion is the date in days since the epoch (1 January 1900) and the fractional portion is the time as a fraction of 24 hours, thus .5 is 12:00 noon. So when you read these values from the spreadsheet you will need to convert them to proper DateTime values before storing them in your dataset.
|
|
|
|
|
hi every one
how to create menu with directx in c#
thanks
|
|
|
|
|
with code.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello,
How we can test if a directory is empty? thank you verry mutch.
|
|
|
|
|
If Directory.GetFiles[^] is not returning any data, consider it is empty.
Best wishes,
Navaneeth
|
|
|
|
|
const string MYDIR = @"C:\MYDIR";
string[] files = Directory.GetFiles(MYDIR);
string[] dirs = Directory.GetDirectories(MYDIR);
if(files.Length == 0 && dirs.Length == 0)
{
}
|
|
|
|
|
Hi,
before .NET 4.0:
the easiest way is testing Directory.GetFileSystemEntries().Length==0 as this method returns the names of all files and folders.
and yes it is a pity you have to ask for a potentially huge array of data just to get a true/false result.
the alternative is to use P/Invoke and use FindFirstFile (not sure if and how that works for subdirectories).
since .NET 4.0 there are new siblings to GetFileSystemEntries and the like (see EnumerateFileSystemEntries) that return results only one at a time and don't burden the CPU and memory that much, as you can opt out right away.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
I want totransfer files from a client to another, using socket programming+c#?
|
|
|
|
|
So on what part are you facing problem?
Best wishes,
Navaneeth
|
|
|
|