I am in the process of moving VB code to C#. However, I have encountered a stumbling block. I have the following code in VB below that uses the Scripting.FileSystemObject and the Scripting.File object. How would I program this property below in C#? Would I use the System.IO.File in place of the Scripting.File object? If so, what would I use for the Scripting.FileSystemObject? Would I open a filestream? If I do, FileSystemObject grabs the whole file, how do I do that using filestreams?
Private mvarFSO As Scripting.FileSystemObject
Private mvarLocalFile As Scripting.File
Public Property Get LocalFile() As Scripting.File
Set mvarLocalFile = Nothing
If mvarFSO.FileExists(mvarMyVSSItem.LocalSpec) Then
Set mvarLocalFile = mvarFSO.GetFile(mvarMyVSSItem.LocalSpec)
Set LocalFile = mvarLocalFile
You can still use the Scripting.FileSystemObject in C# if you would like. The code would be pretty close to what you have already, just change it to use the new syntax. Very quick and easy.
You can also use the IO libraries provided by .NET but you will, obviously, have to re-do all the code that calls this property. Off the top of my head, I can't really tell you what needs to change but I would probably stick with the Scripting.FileSystemObject if you're porting. It's usually easier to change as little as possible and make sure it's working before moving on.
How do you scroll a window in .net? I want to make a RichTextBox scroll to a certain position, without using ScrollToCaret(). I tried using the user32 SetScrollPosition, but that just moves the scroll bar itself. In other words, the scrollbar moves, but the window doesn't scroll.
Is there a ClippingRect object in C#? I can't find it in the Control class..
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
Have somebody seen CodePageEncoding class in the .NET documentation, or in the library? Where it is, or has it been thrown away from the final release?
I really wander whether somebody is using it. This class is referenced in Dr. GUI .NET article #5 (from May 31, 2002 - quite fresh issue). According this article, the CodePageEncoding should be in System.Text namespaces.
However, I'm not able to find it in my libraries. I cannot find it even in the documentation accompanied with VS.NET, as if this class never existed...
Is there a way to read and eventually
store excel files with .net? Possibly
no MSOffice Suite would be installed
on the machine running the program.
I'd like to know a way to read data from
excel spread sheets and access data bases
and to store data in them on a computer
that will not have any of these products
The data will be created with excel and
viewed on a different computers and eventually
modified (very basic modifications).
I need to know this for a windows application
and probably later for ASP .NET application.
Goal is not to replace excel but to create
higly customised program without to use
The problem is so badly explained that you can't be blamed for providing an irrelevant answer. The interop assemblies are only forwarders, and require the stinking Office XP app binaries to do ANYTHING.
Actually, all you need is ADO installed (i.e. the .NET Framework contains the ADO.NET) and you'll need the Microsoft Jet 4.0 installed (download it from the MDAC homepage.
You can use Connection Strings (www.connectionstrings.com) to grab all data from an Excel spreadsheet. This works great if the sheets you'll be reading / writing are in a Table format. If the structure of the spreadsheets are more complicated, you'll need to rely on the Excel object model, which, as you said, may not be installed.
Both Excel and Word store info as OLE Compound document.
You can write to MS (there is an email specified in MSDN) for the file format specification. As for as I can remember Excel uses something called BIFF (Binary File Format etc..) and there is a BIFF reader sample in msdn. Alternately you can also try for the office resource kit which gives you both the file format as well as soom tools to help you sort out things.
All the best.
the above stuff applies to plain old win32, sorry I wasn't thinking of .net.
Last Visit: 31-Dec-99 18:00 Last Update: 3-Oct-23 14:37