|
Hi Christian Graus,
I user administrator username and password to access this path from my pc
actually i dont have rights on that directory so I shared that directory on remote pc.
now I am thinking to write admin username and pwd in my code so that it can be accessed by any pc.
Please tell me how to pass username and pwd with my network path.
Thanking you,
|
|
|
|
|
Hi,
i'm also working on same kind of process.
I want to access files from shared folder in network, but icould not able to access. below i give the code
void imperson()
{
try
{
try
{
DirectoryInfo Dir1 = new DirectoryInfo(@"\\192.168.100.251\StreamManager3\Current");
FileInfo[] FileList1 = Dir1.GetFiles("*.wav");
FileInfo getPrope1 = new FileInfo(@"\\192.168.100.251\StreamManager3\Current\" + FileList1[0].Name);
}
catch (Exception ex)
{
}
ConnectionOptions connec = new ConnectionOptions();
connec.Impersonation = ImpersonationLevel.Impersonate;
connec.EnablePrivileges = true;
connec.Username = "administrator";
connec.Password = "admin";
ManagementScope scope = new ManagementScope(@"\\192.168.100.251\root\cimv2", connec);
//scope.Path = @"192.168.100.251";
scope.Options = connec;
scope.Connect();
DirectoryInfo Dir = new DirectoryInfo(@"\\192.168.100.251\StreamManager3\Current");
FileInfo[] FileList = Dir.GetFiles("*.wav");
FileInfo getPrope = new FileInfo(@"\\192.168.100.251\StreamManager3\Current\" + FileList[0].Name);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
Can you help me whats wrong in the code
S. Ramkumar
|
|
|
|
|
i have to read the column names of excel file and list the column names in a column of grid control..hw can i do that?
|
|
|
|
|
What have you tried ?
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.
|
|
|
|
|
|
|
i have bind dataset to my grid but data of excel is loading in grid instead i need to extract the column names and show them in grid and not data.
|
|
|
|
|
Are you capable of any sort of research ? Of writing any code ? Have you tried anything ?
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.
|
|
|
|
|
yes i m loading excel data to data grid but i need to get column names of my excel file and load those column names in grid
|
|
|
|
|
Someone shoot me.
here[^]
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.
|
|
|
|
|
Come on Christian, what don't you understand? He just needs to get column names of his excel file and load those column names in grid ![WTF | :WTF:](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_WTF.gif)
|
|
|
|
|
Hi,
Give you a example. Hope it is helpful
/************************************************************
from Web
************************************************************/
private void Automation_CellByCell()
{
// Start a new workbook in Excel.
m_objExcel = new Excel.Application();
m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
m_objBook = (Excel._Workbook)(m_objBooks.Add(m_objOpt));
// Add data to cells of the first worksheet in the new workbook.
m_objSheets = (Excel.Sheets)m_objBook.Worksheets;
m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(1));
m_objRange = m_objSheet.get_Range("A1", m_objOpt);
m_objRange.set_Value(m_objOpt,"Last Name");
m_objRange = m_objSheet.get_Range("B1", m_objOpt);
m_objRange.set_Value(m_objOpt,"First Name");
m_objRange = m_objSheet.get_Range("A2", m_objOpt);
m_objRange.set_Value(m_objOpt,"Doe");
m_objRange = m_objSheet.get_Range("B2", m_objOpt);
m_objRange.set_Value(m_objOpt,"John");
// Apply bold to cells A1:B1.
m_objRange = m_objSheet.get_Range("A1", "B1");
m_objFont = m_objRange.Font;
m_objFont.Bold=true;
// Save the workbook and quit Excel.
m_objBook.SaveAs(Application.StartupPath + "\\Book1.xls", m_objOpt, m_objOpt,
m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange,
m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
m_objBook.Close(false, m_objOpt, m_objOpt);
m_objExcel.Quit();
}
private void Automation_UseArray()
{
// Start a new workbook in Excel.
m_objExcel = new Excel.Application();
m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
m_objBook = (Excel._Workbook)(m_objBooks.Add(m_objOpt));
m_objSheets = (Excel.Sheets)m_objBook.Worksheets;
m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(1));
// Create an array for the headers and add it to cells A1:C1.
object[] objHeaders = {"Order ID", "Amount", "Tax"};
m_objRange = m_objSheet.get_Range("A1", "C1");
m_objRange.set_Value(m_objOpt,objHeaders);
m_objFont = m_objRange.Font;
m_objFont.Bold=true;
// Create an array with 3 columns and 100 rows and add it to
// the worksheet starting at cell A2.
object[,] objData = new Object[100,3];
Random rdm = new Random((int)DateTime.Now.Ticks);
double nOrderAmt, nTax;
for(int r=0;r<100;r++)
{
objData[r,0] = "ORD" + r.ToString("0000");
nOrderAmt = rdm.Next(1000);
objData[r,1] = nOrderAmt.ToString("c");
nTax = nOrderAmt*0.07;
objData[r,2] = nTax.ToString("c");
}
m_objRange = m_objSheet.get_Range("A2", m_objOpt);
m_objRange = m_objRange.get_Resize(100,3);
m_objRange.set_Value(m_objOpt,"objData");
// Save the workbook and quit Excel.
m_objBook.SaveAs(Application.StartupPath + "\\Book2.xls", m_objOpt, m_objOpt,
m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange,
m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
m_objBook.Close(false, m_objOpt, m_objOpt);
m_objExcel.Quit();
}
private void Automation_ADORecordset()
{
// Create a Recordset from all the records in the Orders table.
ADODB.Connection objConn = new ADODB.Connection();
ADODB._Recordset objRS = null;
objConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
m_strNorthwind + ";", "", "", 0);
objConn.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
object objRecAff;
objRS = (ADODB._Recordset)objConn.Execute("Orders", out objRecAff,
(int)ADODB.CommandTypeEnum.adCmdTable);
// Start a new workbook in Excel.
m_objExcel = new Excel.Application();
m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
m_objBook = (Excel._Workbook)(m_objBooks.Add(m_objOpt));
m_objSheets = (Excel.Sheets)m_objBook.Worksheets;
m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(1));
// Get the Fields collection from the recordset and determine
// the number of fields (or columns).
System.Collections.IEnumerator objFields = objRS.Fields.GetEnumerator();
int nFields = objRS.Fields.Count;
// Create an array for the headers and add it to the
// worksheet starting at cell A1.
object[] objHeaders = new object[nFields];
ADODB.Field objField = null;
for(int n=0;n
|
|
|
|
|
Hi,
I had an application of BHo developed using Vs2005 c#.
I build a setup in Vs2005.
In the installation folder, I added my dll and Microsoft.Mshtml.dll. In the "Uninstallation" folder also, I added the same (my dll and Microsoft.Mshtml.dll).
while Uninstalling the is an error
"Exception occured while initializing the installation.
'System.IO.FileNotfoundException': could not load file or assembly "file:///C:\Program Files\ AB\SetupName\MyDll.dll' or one of its dependencies. The system cannot find the file specified."
How to solve this?
Now my setup is not getting "UnInstalled". I tried in many ways, but unable to remove it form my "Add or Remove Programs". How to remove this setup from my add remove programs.
|
|
|
|
|
When you add Files that your Application will need in Application Folder, i don't think you need to add then in the uninstall Folder. Only Add what your application will need and when you uninstall your application, all the files in the Programs File --> YourApplicationFolder will be deleted. Why do you want to do it your self
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I am using c# and xml file for storing data (and not in database). How can i add primary key on xml file so that no duplicate data can enter into it.
|
|
|
|
|
I guess you don't really understand what xml is. It's a string, that's about it. You MAY be able to format an XSD to define that data is not duplicated, but if you can or not, any sort of rules you want to enforce, you'll need to write code to enforce them, and you're on your own if you write any bugs.
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.
|
|
|
|
|
i have to iterate through all cells of a column in my grid control and list the values...hw can i do that?
|
|
|
|
|
With for each loops, I expect.
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.
|
|
|
|
|
List them where ?
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
LIQUID NITROGEN
Harvey Saayman - South Africa
Software Developer
.Net, C#, SQL
you.suck = (you.Occupation == jobTitles.Programmer && you.Passion != Programming)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Hi I am I want Ftp Upload File but I have The remote server returned error: (530) did not at logon.
what is problem ?
FtpWebRequest Istek;
try
{
Istek = (FtpWebRequest)FtpWebRequest.Create(new Uri(@"Ftp://" + HostName));
Istek.UseBinary = true;
Istek.Credentials = new NetworkCredential(HostName, Password);
Istek.Method = WebRequestMethods.Ftp.ListDirectory;
WebResponse elcavab = Istek.GetResponse();
|
|
|
|
|
|
Hi,
i think your codes are right.
my codes:
//create the ftpwebrequest object.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(textServer.Text);
request.Credentials = new NetworkCredential(textUsername.Text, textPassword.Text);
request.Method = WebRequestMethods.Ftp.ListDirectory;
//send the request to the server.
response = (FtpWebResponse)request.GetResponse();
//read the response and fill the list box.
stream = response.GetResponseStream();
FillDirectoryList(stream);
..............................
the error may be : the host user is not logined. the host's ftp is closed.
try to use 'cmd' to check, ping that 'IP'.
modified 27-May-14 5:36am.
|
|
|
|
|
I have developed a control. Among other things this control can popup other controls at runtime. When you include the assembly in Visual Studio, the control that I created shows up, but the other controls (the ones my control uses) show up as well. I would rather not have them show up in the toolbox in Visual Studio. Is there an Attribute that I can apply to these classes to make them not show up? I found the browsable attribute, but it says it is for properties and events.
Tanks for your support
Pat O
<a href="http://currentchaos.blogspot.com/">Blog</a>
_ _ _
|
|
|
|
|
Try System.ComponentModel.ToolboxItemAttribute
[System.ComponentModel.ToolboxItem(false)]
public class YourControl : YourBaseControl
{
}
|
|
|
|