|
there is a very good reason.
consider inheritance....
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
I, too, am still learning about all of this stuff. So I probably know only enough to get myself in trouble.
This is what I know so far about this
If you have multiple threads of an object, I believe that this will differentiate between current thread and some other thread. (or maybe the parent thread(???))
In all of the web examples I've seen there is a heavy use of this for accessing the form fields.
In inherited classes, this also identifies you are refering to a property/method within THIS class vs. the BASE class. (even though you cannot access base methods WITHOUT the base qualifier!)
With the exception of those two reasons, this just makes it easy to pull up an intellisense box while coding.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Need a function that will return certain system information into a text box.
User Name
Computer Name
Logged into Domain (Yes or No) If Yes then the Domain Name
Logged into Workgroup (Yes or No) If Yes then the Workgroup Name
OS Version
Any Service packs installed?
Listing of Mapped Drives
Thanks,
Derek
|
|
|
|
|
|
oops...forgot to paste these in look here [^]
and here [^]....this should also help
best of luck
Fill me with your knowledge, your wisdom, your coffee.
|
|
|
|
|
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?
VB Code...
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)
End If
Set LocalFile = mvarLocalFile
End Property
C# Translation...
private something_like_FileSystemObject mvarFSO;
private something_like_File_object mvarLocalFile;
public return_type LocalFile
{
get
{
???
return mvarLocalFile;
}
}
Help please, I'm stumped...
Eric
|
|
|
|
|
Not sure how much help this will be but...
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.
Cheers,
steve
|
|
|
|
|
Hello, the codegurus around the world.;)
Just hints.
try
{
string tempS = "You need the right path";
FileSystemObject fso = new FileSystemObject();
Scripting.File fInfo = fso.GetFile(tempS);
}
catch {fInfo = null;}
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
using System.IO;
...
private FileInfo mvarLocalFile;
public FileInfo LocalFile
{
get
{
string path = mvarMyVSSItem.LocalSpec;
if (File.Exists(path))
mvarLocalFile = new FileInfo(path);
else
mvarLocalFile = null;
return mvarLocalFile;
}
}
|
|
|
|
|
I would use the System.IO namespace... To me it's more of a cleaner interface than the plain old FileSystemObject. Though I'm partial to C#.
System.IO.FileInfo fileinfo = new System.IO.FileInfo(filename);
fileinfo.Open(System.IO.FileMode.OpenOrCreate);
|
|
|
|
|
Thank you for the help, I got it to work with the code you wrote. Thanks richard_d (on both sites) and joan_fl!!!
|
|
|
|
|
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."
-Groucho Marx
|
|
|
|
|
Hi you can make one! But just for the RichTextBox...
private Size contentsize = Size.Empty;
protected Size ContentSize
{
get
{
return contentsize;
}
}
protected override void OnContentsResized ( ContentsResizedEventArgs e )
{
contentsize = e.NewRectangle.Size;
base.OnContentsResized(e);
}
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
And the other part...
[Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
protected Point ScrollPosition
{
get
{
Point pt = Point.Empty;
User32.SendMessage(base.Handle, Constants.EM_GETSCROLLPOS, 0, ref pt);
return pt;
}
set
{
User32.SendMessage(base.Handle, Constants.EM_SETSCROLLPOS, 0, ref value);
}
}
Obviously you just need to define a User32.SendMessage like:
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, ref Point lParam);
CHeers
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
|
How do you associate a file type (extension) with your application (in .NET if possible)?
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
I think this can be done through registry
- Kannan
|
|
|
|
|
Look in the deployment projects... there's a real easy way to add it. Not 100% sure how to implement something such as an "OPEN" when the file is 2x-clicked.
-AC
MCDBA
http://www.aconnell.com
|
|
|
|
|
|
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...
Vasek
VB6, C#, MS DNA, MS .NET software developer
|
|
|
|
|
Excerpt from MSDN:
Encoding Constructor (Int32) [C#]
Initializes a new instance of the Encoding class.
[C#]
[Serializable]
protected Encoding(
int codePage
);
Parameters
codePage
A code page value that corresponds to the preferred encoding.
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
System.Text.Encoding.Default is for your current system codepage, but if you need others you will have to go the way above.
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
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
available.
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
excel itself.
(what about MS word documents?)
|
|
|
|
|
You can work with Office XP via .NET.
Office XP Primary Interop Assemblies[^]
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
Unfortunatly he says this
"Possibly no MSOffice Suite would be installed on the machine running the program." So the interop assemblies won't help.
There is a product out there somewhere which can write excel documents; IIRC it was advertised a lot on ASP-oriented developer sites. I want to say it was by SoftArtisians but I can't remember.
What do you know... ExcelWriter 4.0[^]
James
- out of order -
|
|
|
|