|
I do!
File.Move(...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
i have a txt Structured file as Ascii. i can read information of that file as structure.
that structure is same as follow:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
private struct Header
{
public byte version;
public Int32 numRecords;
public Int16 headerLen;
public Int16 recordLen;
public byte encryptionFlag;
public Int64 reserved;
....
}
when writing in file , i need to change one /two field of file e.g numRecords.
how can i write this instance file writing? i tried following code but file destroyed and i couldn't read file
using (OpenFileDialog of=new OpenFileDialog())
{
of.ShowDialog();
FileStream fs = new FileStream(of.FileName,FileMode.Open,FileAccess.ReadWrite);
BinaryWriter bw = new BinaryWriter(fs);
BinaryReader br = new BinaryReader(fs);
byte[] buffer = new byte[Marshal.SizeOf(typeof(Header))];
buffer = br.ReadBytes(Marshal.SizeOf(typeof(Header)));
GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
Header rHeader = ((Header)(Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Header))));
handle.Free();
Header wHeader = rHeader;
wHeader.numRecords = 5;
IntPtr ptr = Marshal.AllocHGlobal(buffer.Length);
Marshal.StructureToPtr(wHeader, ptr, true);
Marshal.Copy(ptr, buffer, 0, buffer.Length);
Marshal.FreeHGlobal(ptr);
bw.Seek(0, SeekOrigin.Begin);
bw.Write(buffer);
bw.Close();
br.Close();
fs.Close();
}
|
|
|
|
|
|
I have been consuming (looking at) the results I see from a web service that I am going to obtain to call. As part of the process, I started a shell C# 2010 app that will look at the information obtained from the web service. I have been able to obtain the PDF documents by specifying where those files should be located in an app.config file.
However my problem is obtaining the results of an xml and an xsd file. The xml/xsd information is not saved to any file. This information is displayed in a dos prompt window when I run a command script. I have been able to save the output to a text file by doing a redirection statement to write the information to a text file.
However I would like to know how I can capture the xsd/xml file so that I can parse through the information to extract the specific information I am looking for.
Thus, can you tell me and/or point me to a reference that will tell me how to accomplish this task?
|
|
|
|
|
If you're starting the process with Process.Start, you can redirect its stdout to a stream you control. See here[^].
|
|
|
|
|
Thank you!
I have the following addtional questions:
1. How can I save the data in an xml format that I can parse through?
2. How can I parse through the xml data? Would I use something like an xml.exe and/or xsd.exe to create the classes? How would this help me parse through the data?
|
|
|
|
|
You can use XSD to create auto-generated classes from a schema, and then there's some easy way to load a file into a class hierarchy based on that (which I currently forget, sorry about that, it's a while since I did any of that stuff). If you have a fixed schema that's probably the way to go.
You should be able to push the redirected stdout into a MemoryStream, and then use that to create an object tree, without needing to ever create a file.
|
|
|
|
|
I have one additional question.
The information appears in a dos popup window. Can you tell me how to obtain the information from a dos popup window?
|
|
|
|
|
If you're redirecting the standard streams then the console shouldn't appear any more, if it's a normal command line process. The fact that you can > redirect the output suggests it is going to stdout.
Are you using Process.Start to start this process? You need to set UseShellExecute to false (I think that was in the link I posted before) and RedirectStandardOutput, Error and Input to true to make the console disappear, if I remember right.
|
|
|
|
|
Hi All,
I have created a user control which draws some items on a bitmap. This control is scrollable and we can also pan it.
I am using Microsof.Gesture/PhysicsEngine library for controlling gestures.
The full scenario is like I create the full bitmap only once and after that when I do any gesture like scroll or pan i just show particuler portion of the bitmap but it has lot of flickering. Following is the code sample:
protected override void OnPaintBackground(PaintEventArgs e)
{
}
private Bitmap _cachedBitmap;
protected override void OnPaint(PaintEventArgs e)
{
using (Graphics g = e.Graphics)
{
if (!_isPainted)
{
_cachedBitmap = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
InitilizeBitmap(g);
_isPainted = true;
}
Rectangle rec = new Rectangle(0, _bitmapLocation.Y, ClientRectangle.Width, ClientRectangle.Height);
g.DrawImage(_bmpControl, 0, 0, rec, GraphicsUnit.Pixel);
}
}
Any idea how can I avoid flickering ?
Praveen Sharma
|
|
|
|
|
|
I am using .Net Compact Framework FYI.
There is nothing like:
DoubleBuffered = true;
Praveen Sharma
|
|
|
|
|
Sorry, missed that. It looks like the old fashioned SetStyle call isn't there either.
|
|
|
|
|
Have a look at this[^] article to get some ideas on double buffering in Compact Framework.
|
|
|
|
|
This article is just bad, just for kids to play.
Praveen Sharma
|
|
|
|
|
How big is the bitmap?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
It's 200 * 2000 (width * height )
Praveen Sharma
|
|
|
|
|
Care to link to an example? I'm wondering whether that 2000 could be reduced.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I got this error in my code:
Cannot add part for the specified URI because it is already in the package
At this line:
var chart = xlSheets.Drawings.AddChart(dataSet.DataSetName, OfficeOpenXml.Drawing.Chart.eChartType.ColumnClustered);
I am trying to create multiple sheets.
Anyone know how to fix this?
THANKS in advanced~
|
|
|
|
|
As this is a CodePlex project, the best place to ask would be the support forums for that package on CodePlex itself. When you post a question there, the developers will be notified.
|
|
|
|
|
Anyone know how to set title for Xaxis and Yaxis?
I can't find it.
|
|
|
|
|
I cannot figure out the syntax for using the LINQ extensions on IList (and other interfaces) to search for values that are in nested objects.
For instance, I have a List<foo>, where object foo contains two other objects, each of which have field "data".
How do I use List.Contains<foo>("hello") to search for a foo object where foo.nestedobject.data = hello?
|
|
|
|
|
Why not ask in the LINQ forum where the LINQ guru's hang out?
|
|
|
|
|
Thanks. I asked here because it's not obvious that object.contains() is actually a LINQ extension. Sadly, you can't do what I want with object.contains(), which does not let you compare nested values directly.
Turns out that what I need is
foo.Any(f => f.bar.data == "hello")
Which makes me a little sad, because
foo.Contains(nested value I was looking for)
would have been a lot simpler than having to break out my book and re-learn lambdas. Oh well, wave of the future
|
|
|
|
|
How could Contains() have any "idea" in which properties of foo to look for some value?
For instance, should it look in all properties that are the same type as the value to find? What if it is nested arbitrarily deep?
The only rational behavior is for the developer to be responsible to structure the query.
Re: lambdas... they're not that hard!
|
|
|
|