|
hi friends
i want to retrive hard disk serial no.
i use this code
Dim strMotherBoardID As String = String.Empty
Dim query As New SelectQuery("Win32_BaseBoard")
Dim search As New ManagementObjectSearcher(query)
Dim info As ManagementObject
For Each info In search.Get()
strMotherBoardID = info("SerialNumber").ToString()
Next
Return strMotherBoardID
but this code does not work properly.
this error show
Object reference not set to an instance of an object.
|
|
|
|
|
|
hi
this code work on normal hard disk.
but on sata hard disk this code does not work.
|
|
|
|
|
Hi. This is a C# forumn. Try the VB forumn for VB help.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
dear
i have solution in C#
plz tell me
|
|
|
|
|
If you are using VS2008 and .net 3.5 you can use the System.Management namespace. Have a look at this link.
Search HDD Serial Number[^]
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Hi All,
I have an Object collection on which I would like to use Linq query based upon the some criteria.
Can anybody please give me any links or a small code snippet to complete this task.
Thanks,
Md. Abdul Aleem.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
|
I suggest you post this in the linq forum - you will get a more positive response.
This site was useful to me as well msdn[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Guys,
I have created a text file 'sample.txt' using FileStreamWriter property of C#, where I have entered this following sample HTML code:
<title>Sample WebPage
This is a sample webpage created using Filestream
However, the following code is in Notepad and wont be converted into a WebPage untill I change the extension of the File from .txt to .html.
Therefore, my question is, how can I convert a .txt file to .html, programatically? I also want to rename the filename 'Sample.txt' to 'Mypage.html'. Is there any 'rename' function in C#? Please help me.
Your help will truly be appreciated,
Thanx for taking interest in my question,
Rajdeep.NET
|
|
|
|
|
U need to use a fileInfo class..
FileInfo fln = new FileInfo(fl); //Here the fl is the string containing the location of your text
file.
//Now you have two options either copy to another file using this function
string temp = fl.Split('.')[0]; //This will remove .txt from file address.
fln.CopyTo(temp + ".html"); //This will create a new file with .html extension.
fln.Delete(); //Deletes the .txt file.
// OR you can do is use replace function
fln.Replace(fl,temp + ".html");
//But i am not sure this 2nd one works ..
|
|
|
|
|
Hi Jay,
Thanx for posting the code. Everything is fine except the System namespace. I am using System.IO; as the system namespace, but an error is displayed saying, "System.IO.FileInfo does not contain a definition for 'Split' ". Please provide me the appropriate namespace.
Thanx
Rajdeep.NET
|
|
|
|
|
Use all this...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
|
|
|
|
|
Hi Jay,
Can u please explain me why shall I use the Using System.Windows.Forms; in my console application?
However, it worked fine for me. But, take a look at this code:
System.IO.File.Move(@"C:/from.txt", @"C:/to.html");
This one is a short one but workd overwhelmingly fine. We have to use the Move function because, C# doesn't support 'rename' function like C.
Thanx for your help again,
Happy programming and wish u a successful programming career,
Rajdeep.NET
|
|
|
|
|
I thought you are asking for a windows application ??
|
|
|
|
|
Yep, that one line of code is all you need to what you want. I'd ignore some of the poor advice about including numerous irrelevant namespaces and manipulating strings and copying files....
Regards,
Rob Philpott.
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace Extensionchanges
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog OpenFileDialog1 = new OpenFileDialog();
OpenFileDialog1.ShowDialog();
string fl = OpenFileDialog1.FileName;
FileInfo fln = new FileInfo(fl);
string temp = fl.Split('.')[0];
fln.CopyTo(temp + ".html");
}
|
|
|
|
|
The above windows application code show an error:
The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)
Why so?
|
|
|
|
|
Its of framework 3.5
remove it if you use 3.0 framework
|
|
|
|
|
Hey Jay,
Sorry man, but I'm using VS.NET 2005 and unfortunately my system is running on .NET framework 2.0. What will I do now?
|
|
|
|
|
Rajdeep.NET wrote: What will I do now?
Follow Rob's advice[^] and don't use all those namespaces! The code you're using isn't using Linq (not available in 2.0 anyway), so just delete the offending line.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
You really dont need LINQ assembly,as it is not used anyway . ..
Just delete any assembly that gives error...
The code is just very simple.. I am unable to understand why you get an error...
|
|
|
|
|
In addition to the advice already received, take a look at the Path.ChangeExtension(pathToFile, newExtension) static method.
You know, if I was looking for a way to change a file extension, one of the first things I would have done is to google for 'change extension (c# OR vb)'. I haven't done that in this case since my ageing brain cells still held the correct information, but why don't you give it a try? Do you want to have a small wager that this solution would be right there at, or very near, the top? If you had done that, it would have saved you 25 minutes, that could be used for productive work.
Any way, others seem to have given you a solution that works, so good luck with whichever way you choose to go.
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.”
|
|
|
|
|
How can I access to properties or methods of a control from another forms? Or How can I send information from form to another forms?
Thanks.
|
|
|
|
|