|
Hi
I am using this code to upload a file to my server but on some computers like 1% of users it doesn't upload the file to the server. After trying to connect on that PC which has the problem, with Filezilla to my server I see that it fails to make the connection because it can't pass the SSL/TLS authentication part.
public static void Upload(string strLocalFileName,string strRemoteFileName, string strUsername, string strPassword)
{
WebRequest wreq = WebRequest.Create(HTTPloc.fileserverurl + strRemoteFileName);
FtpWebRequest ftp = (FtpWebRequest)wreq;
ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback;
ftp.Credentials = new NetworkCredential(strUsername, strPassword);
ftp.Method = WebRequestMethods.Ftp.UploadFile;
ftp.UsePassive = true;
ftp.UseBinary = true;
ftp.KeepAlive = false;
ftp.EnableSsl = true;
FileStream stream = File.OpenRead(strLocalFileName);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Close();
Stream reqStream = ftp.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
}
The exception it throws is something like "remote computer didn't answer in the time provided" actually it defines timeout.
User tried OS reinstall but still the same problem. It has to be a problem with the things he does after installation. Any ideas? What causes a problem on SSL TLS authentication?
Thanks.
|
|
|
|
|
Good morning.
I set several global variables to be used throughout the form code and when I need to reference the strContainer in the WorkerImport_ProgressChanged event, the value is Null for some reason. It is fine in the Submit event and passed successfully to the WorkerImport_DoWork event. Any idea why the strContainer is Null? My understanding is,with Win form apps the WorkerImport_ProgressChanged event operates on the main (GUI) thread. The code is as follows:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Collections;
using System.IO;
using System.Xml.Linq;
using System.Configuration;
using System.Threading;
namespace IPControl
{
public partial class ucWAH : UserControl
{
string strContainer = String.Empty;
string strDave = String.Empty;
object[] obj;
ArrayList ar = new ArrayList();
FormFunctions ff = new FormFunctions();
UIPCMainForm uipc;
VariableDefs vd = new VariableDefs();
const string constrLocation = "Chattanooga";
const string constrSubnet = "/29 - Standard Work at Home";
const string constrRouter = "Cisco 999";
const string constrEUDepart = "Contact Center";
ArrayList arSubNetList = new ArrayList();
ArrayList arDHCPOptionList = new ArrayList();
ArrayList arDHCPPolicyList = new ArrayList();
ArrayList arAllocationTemplateList = new ArrayList();
string strWAHSuffix = ConfigurationSettings.AppSettings["WAH_SUFFIX"];
public ucWAH()
{
InitializeComponent();
}
#region Work at Home Form Events
private void ucTabs_Load(object sender, EventArgs e)
{
PwdSecurity p = new PwdSecurity();
uipc = this.Parent as UIPCMainForm;
DAL d = new DAL(uipc.StrUserName, p.base64Decode(uipc.StrPassword));
DataSet ds = new DataSet();
#region Populate Drop Downs
ds = d.FillDropDowns(1);
if (checkForEmptyDataset(ds)) return;
if (ds == null)
{
return;
}
cbLocation.DataSource = ds.Tables[0];
cbLocation.DisplayMember = vd.STR_COLUMN_NEAR_LOCATION;
cbLocation.ValueMember = vd.STR_COLUMN_LOCATION;
foreach (DataRow dr in ds.Tables[0].Rows)
{
arDHCPOptionList.Add(dr[vd.STR_COLUMN_DHCP_OPTION]);
arDHCPPolicyList.Add(dr[vd.STR_COLUMN_DHCP_POLICY]);
}
ds = null;
ds = d.FillDropDowns(2);
if (checkForEmptyDataset(ds)) return;
cbRouter.DataSource = ds.Tables[0];
cbRouter.DisplayMember = vd.STR_COLUMN_ROUTER_TYPE;
cbRouter.ValueMember = vd.STR_COLUMN_DM_VPN_CLOUD;
ds = null;
ds = d.FillDropDowns(3);
if (checkForEmptyDataset(ds)) return;
cbSubnet.DataSource = ds.Tables[0];
cbSubnet.DisplayMember = vd.STR_COLUMN_SUBNET_SIZE;
cbSubnet.ValueMember = vd.STR_COLUMN_DMVPN_SUBNET_TYPE;
foreach (DataRow dr in ds.Tables[0].Rows)
{
arSubNetList.Add(int.Parse(dr[vd.STR_COLUMN_SUBNET_BLOCK_SIZE].ToString()));
arAllocationTemplateList.Add(dr[vd.STR_COLUMN_SUBNET_ALLOCATION_TEMPLATE].ToString());
}
ds = null;
ds = d.FillDropDowns(5);
if (checkForEmptyDataset(ds)) return;
cbEndUserDepart.DataSource = ds.Tables[0];
cbEndUserDepart.DisplayMember = vd.STR_COLUMN_ROUTER_CATEGORY;
cbEndUserDepart.ValueMember = vd.STR_COLUMN_ONE_DIGIT_CODE;
string strAppConfigRouterConfigs = ConfigurationSettings.AppSettings["WAH_ROUTER_CONFIGURATION_TYPES"];
string[] strRouterConfigs = strAppConfigRouterConfigs.Split(',');
cbRouterConfig.DataSource = strRouterConfigs;
cbRouterConfig.SelectedIndex = 0;
#endregion
ff.ControlSetFocus(cbEndUserDepart);
cbEndUserDepart.SelectAll();
uipc = this.Parent as UIPCMainForm;
uipc.AcceptButton = btnSubmit;
uipc.Width = 800;
uipc.Height = 600;
#region Set up progress bar thread
#endregion
}
private void ucTabs_Leave(object sender, EventArgs e)
{
uipc.AcceptButton = null;
}
#endregion
#region Work From Home Button Events
private void btnReset_Click(object sender, EventArgs e)
{
tbRACFID.Text = string.Empty;
tbRACFID.Enabled = true;
tbUserName.Text = string.Empty;
cbEndUserDepart.Text = constrEUDepart;
cbLocation.Text = constrLocation;
cbSubnet.Text = constrSubnet;
cbRouter.Text = constrRouter;
cbRouterConfig.SelectedIndex = 0;
ff.ControlSetFocus(tbRACFID);
}
private void btnSubmit_Click(object sender, EventArgs e)
{
PwdSecurity p = new PwdSecurity();
DAL d = new DAL(uipc.StrUserName, p.base64Decode(uipc.StrPassword));
BackgroundWorker WorkerImport = new BackgroundWorker();
WorkerImport.WorkerReportsProgress = true;
WorkerImport.WorkerSupportsCancellation = true;
WorkerImport.DoWork += new DoWorkEventHandler(WorkerImport_DoWork);
WorkerImport.ProgressChanged += new ProgressChangedEventHandler(WorkerImport_ProgressChanged);
WorkerImport.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkerImport_RunWorkerCompleted);
if (tbRACFID.Text == string.Empty)
{
MessageBox.Show("You must have a RACFID in order to continue.", "RACFID Field Validation", MessageBoxButtons.OK, MessageBoxIcon.Stop);
ff.ControlSetFocus(tbRACFID);
return;
}
if (tbUserName.Text == string.Empty)
{
MessageBox.Show("You must have a User Name in order to continue.", "User Name Field Validation", MessageBoxButtons.OK, MessageBoxIcon.Stop);
ff.ControlSetFocus(tbUserName);
return;
}
string strContainer = cbEndUserDepart.SelectedValue.ToString() + tbRACFID.Text.ToLower();
ArrayList ar = new ArrayList();
ar.Add(strContainer);
ar.Add(tbUserName.Text);
ar.Add(cbRouter.SelectedValue.ToString());
ar.Add(cbRouter.Text);
ar.Add(cbRouterConfig.Text);
ar.Add((int)arSubNetList[cbSubnet.SelectedIndex]);
ar.Add(cbSubnet.SelectedValue.ToString());
ar.Add(arDHCPOptionList[cbLocation.SelectedIndex].ToString());
ar.Add(arDHCPPolicyList[cbLocation.SelectedIndex].ToString());
ar.Add(arAllocationTemplateList[cbSubnet.SelectedIndex].ToString());
ar.Add(tbUserName.Text);
WorkerImport.RunWorkerAsync(ar);
#region deactivated code
#endregion
#endregion Work From Home Button Events
}
#region WorkerImport_DoWork
void WorkerImport_DoWork(object sender, DoWorkEventArgs e)
{
PwdSecurity p = new PwdSecurity();
DAL d = new DAL(uipc.StrUserName, p.base64Decode(uipc.StrPassword));
BackgroundWorker worker = (BackgroundWorker)sender;
worker.ReportProgress(0);
ar = (ArrayList)e.Argument;
string strContainer = (string)ar[0];
string tbUserName = (string)ar[1];
string cbRouter_SelectedValue = (string)ar[2];
string cbRouter_Text = (string)ar[3];
string cbRouterConfig_Text = (string)ar[4];
int arSubNetList = (int)ar[5];
string cbSubnet_SelectedValue = (string)ar[6];
string arDHCPOptionList = (string)ar[7];
string arDHCPPolicyList = (string)ar[8];
string arAllocationTemplateList = (string)ar[9];
string tbUserName2 = (string)ar[10];
obj =
d.importContainer(
strContainer,
tbUserName,
cbRouter_SelectedValue,
cbRouter_Text,
cbRouterConfig_Text,
arSubNetList,
cbSubnet_SelectedValue,
arDHCPOptionList,
arDHCPPolicyList,
arAllocationTemplateList,
tbUserName2
);
if (bool.Parse(obj[0].ToString()))
{
worker.ReportProgress(1);
}
else
{
worker.ReportProgress(2);
}
}
#endregion WorkerImport_DoWork
#region WorkerImport_ProgressChanged
void WorkerImport_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
StreamWriter SW;
XDocument xmlDoc;
switch (e.ProgressPercentage)
{
case 0:
SetProgressBarMarquee();
Cursor.Current = Cursors.WaitCursor;
break;
case 1:
SetProgressBarContinuous();
Cursor.Current = Cursors.Default;
string strMessage =
"You have successfully imported your Router information into IPControl. \r\n \r\n" +
"Would you like to procede with creating the configuration file to \r\n" +
"store on a Removable drive?" + "\r\n \r\n" +
"IMPORTANT NOTE: Please note the configuration file will be lost by answering No" + "\r\n" +
"to this question, and cannot be regenerated without considerable effort.";
DialogResult result;
result = MessageBox.Show(strMessage,
"IPControl Import Complete",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
xmlDoc = XDocument.Parse(obj[1].ToString());
XElement Results = XElement.Parse(xmlDoc.ToString());
string strFileName = strContainer + strWAHSuffix + ".txt";
#region Locate any removable drives
ArrayList alDriveLetter = new ArrayList();
foreach (System.IO.DriveInfo f in System.IO.DriveInfo.GetDrives())
{
if (f.DriveType.ToString() == "Removable")
{
alDriveLetter.Add(f.Name);
}
}
#endregion
if (alDriveLetter.Count == 1)
{
strMessage = "Removable drive " + alDriveLetter[0].ToString() + " was found. Would you " +
"like to save your configuration file to drive " + alDriveLetter[0].ToString() + "? \r\n \r\n" +
"IMPORTANT NOTE: Please note the configuration file will be lost by answering No" + "\r\n" +
"to this question, and cannot be regenerated without considerable effort.";
SetProgressBarMarquee();
result = MessageBox.Show(strMessage,
"Removable Drive Found",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
SW = File.CreateText(alDriveLetter[0].ToString() + strFileName);
foreach (XElement xe in Results.Descendants())
{
if (xe.HasElements)
{
foreach (XElement xeDesc in xe.Descendants())
{
if (xeDesc.Value != null)
{
SW.WriteLine(xeDesc.Value);
}
}
}
}
SW.Close();
SetProgressBarContinuous();
MessageBox.Show(
"Configuration file " + strFileName + " has saved to directory: " + alDriveLetter[0].ToString(),
"File Saved",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else if (result == DialogResult.No)
{
SetProgressBarContinuous();
btnReset.PerformClick();
return;
}
}
else
{
strMessage =
"More than one Removable drive was found, or no removable \r\n" +
"drives were found. After pressing OK, you will need \r\n" +
"to choose a location to save your configuration file. \r\n \r\n" +
"IMPORTANT NOTE: Please note the configuration file will be lost by Cancelling" + "\r\n" +
"when selecting your file output location.";
result = MessageBox.Show(strMessage,
"Choose location to save configuration file",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
FolderBrowserDialog fbd = new FolderBrowserDialog();
string strFolderName = string.Empty;
SetProgressBarMarquee();
DialogResult dr = fbd.ShowDialog();
if (dr == DialogResult.OK)
{
strFolderName = fbd.SelectedPath;
SW = File.CreateText(strFolderName + strFileName);
foreach (XElement xe in Results.Descendants())
{
if (xe.HasElements)
{
foreach (XElement xeDesc in xe.Descendants())
{
if (xeDesc.Value != null)
{
SW.WriteLine(xeDesc.Value);
}
}
}
}
SW.Close();
SetProgressBarContinuous();
MessageBox.Show(
"Configuration file " + strFileName + " has saved to directory: " + strFolderName,
"File Saved",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
SetProgressBarContinuous();
return;
}
}
btnReset.PerformClick();
}
break;
case 2:
SetProgressBarContinuous();
Cursor.Current = Cursors.Default;
btnReset.PerformClick();
break;
}
}
#endregion WorkerImport_ProgressChanged
#region WorkerImport_RunWorkerCompleted
void WorkerImport_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
}
#endregion WorkerImport_RunWorkerCompleted
#region Work From Home field events
private void tbUserName_Enter(object sender, EventArgs e)
{
tbRACFID.Enabled = false;
if (tbRACFID.Text == string.Empty)
{
MessageBox.Show("You must have a RACFID in order to continue.", "RACFID Field Validation", MessageBoxButtons.OK, MessageBoxIcon.Stop);
tbRACFID.Enabled = true;
ff.ControlSetFocus(tbRACFID);
return;
}
EEInfo ee = new EEInfo();
string strName = String.Empty;
Cursor.Current = Cursors.WaitCursor;
try
{
ee.EE(tbRACFID.Text.ToUpper());
if (ee.StrPreferredFirstName == string.Empty && ee.StrLastName == string.Empty)
{
Cursor.Current = Cursors.Default;
string strMessage =
"The RACFID or LAN ID you entered is not a valid ID. \r\n \r\n" +
"Would you like to continue with the ID you entered?";
DialogResult result;
result = MessageBox.Show(strMessage,
"RACFID/Lan ID not Found",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
tbRACFID.Text = Regex.Replace(tbRACFID.Text, @"[^\w\.]|_", "");
ff.ControlSetFocus(tbUserName);
}
else
{
tbRACFID.SelectAll();
tbRACFID.Enabled = true;
ff.ControlSetFocus(tbRACFID);
}
}
else
{
tbRACFID.Text = Regex.Replace(tbRACFID.Text, @"[^\w\.]|_", "");
tbUserName.Text = ee.StrPreferredFirstName + " " + ee.StrLastName;
ff.ControlSetFocus(cbLocation);
}
}
catch (Exception ex)
{
Cursor.Current = Cursors.Default;
MessageBox.Show(
"tbUserName_Enter method error. \n\r \n\r" + ex.Message,
"Error in User Name Routine",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
#endregion
private bool checkForEmptyDataset(DataSet ds)
{
bool booEmpty = false;
if (ds.Tables.Count < 1)
{
uipc = this.Parent as UIPCMainForm;
uipc.Width = 800;
uipc.Height = 600;
booEmpty = true;
}
return booEmpty;
}
private void SetProgressBarMarquee()
{
uipc.progressBar1.Style = ProgressBarStyle.Marquee;
uipc.progressBar1.MarqueeAnimationSpeed = 50;
}
private void SetProgressBarContinuous()
{
uipc.progressBar1.Style = ProgressBarStyle.Continuous;
uipc.progressBar1.Value = 0;
}
}
}
Thank you for taking the time to peruse this post. WHEELS
|
|
|
|
|
This may or may not be the cause of your problem - there's way too much code there to plough through to be sure...
In your DoWork handler your creating a local variable strContainer and not using the global one
string strContainer = (string)ar[0]; If you meant to use the global one just drop the string at the start
strContainer = (string)ar[0];
|
|
|
|
|
Hi Dave.
That's exactly what happened. When I removed the 'string', it displayed correctly. Very strange.
Sorry for the huge posting everyone.
Have a great day,
WHEELS
|
|
|
|
|
Cool glad you've got it sorted.
Don't forget to aquire a lock on it as you're in a different thread in the DoWork handler, if it were accessed/modified from two threads at once you would have problems!
|
|
|
|
|
Hi,
Have you tried "Find All References" on the strContainer field. I haven't managed to read all of your code snippet(!) but I think you will find it is unassigned.
The btnSubmit_Click method declares a local variable strContainer, probably not what you meant to do.
Alan.
|
|
|
|
|
When trying to find the solution to a problem such as this I often set up a quickie test project with all the irrelevant stuff removed such as...
using System.ComponentModel;
using System.Windows.Forms;
namespace TestBGW
{
public partial class Form1 : Form
{
private BackgroundWorker backgroundWorker;
private string testString;
public Form1()
{
InitializeComponent();
backgroundWorker = new BackgroundWorker();
backgroundWorker.WorkerReportsProgress = true;
backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
testString = "A";
backgroundWorker.RunWorkerAsync(testString);
}
void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
string passedThrough = (string)e.Argument;
passedThrough = "B";
backgroundWorker.ReportProgress(0, passedThrough);
}
void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
MessageBox.Show(string.Format("{0} - {1}", testString, e.UserState));
}
}
} By the way, if you are accessing values that are not local to the DoWork handler inside it, you should aquire a lock on them first
|
|
|
|
|
Although I have all datatable columns set to accept DBNull, my application throws this exception:
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public System.DateTime ArrangementDate {
get {
try {
return ((global::System.DateTime)(this[this.tablePaymentArrangements.ArrangementDateColumn]));
}
catch (global::System.InvalidCastException e) {
throw new global::System.Data.StrongTypingException("The value for column \'ArrangementDate\' in table \'PaymentArrangements\' is DBNull.", e);
}
}
set {
this[this.tablePaymentArrangements.ArrangementDateColumn] = value;
}
}
I'm stumped (right now). Any pointers would be much appreciated please.
|
|
|
|
|
Hi,
I think DBNull is not compatible with DateTime . You should check if it is DBNull.Value and then send null back.
greetz
|
|
|
|
|
If that is a strongly typed dataset, you'll find it has an bool IsArrangementDateNull() method. You should use this to check before trying to read the value.
The reason for this is there is no way to cast DBNull.value to a DateTime.
|
|
|
|
|
DateTime is not nullable.
|
|
|
|
|
Hi all,
I have a bunch of H264 files with corrupt video profiles (showing a level of 20!) which means they dont work in Windows 7 or on my Xbox 360
I've fixed a few files by opening them up in a hex editor and searching for
61 76 63 43 01 4D 00 C8 FF E1 00 13 67 4D 00 C8
(note the 4D 00 C8 is the profile and level [C8 being the corrupt level])
and I replace this string with
61 76 63 43 01 4D 00 20 FF E1 00 13 67 4D 00 20
[changing the occurrence of C8 to 20 to make the level 3.2]
I have about 300 more mp4 files to do and I dont want to do them by hand, so is there an easy way I can read this in to c# and make the find and replace, then output the file again?
I know I can use things like streamreaders/writers and binary readers/writers, but if someone could offer some simple code on how to do it then it saves me asking bit by bit questions on how to do it
Thanks
|
|
|
|
|
Just sample...
const string SOURCE = @"D:\myFile.bin";
const string TARGET = @"D:\myNewFile.bin";
const string TOSEARCH = "4D-00-C8";
const string REPLACEWITH = "4D-00-20";
byte[] byteArray = File.ReadAllBytes(SOURCE);
string byteString = BitConverter.ToString(byteArray);
if (byteString.Contains(TOSEARCH))
{
string newByteString = byteString.Replace(TOSEARCH, REPLACEWITH);
string[] newByteStringSplitted = newByteString.Split('-');
byte[] newByteArray = new byte[newByteStringSplitted.Length];
for (int i = 0; i < newByteArray.Length; i++ )
{
newByteArray[i] = byte.Parse(newByteStringSplitted[i], NumberStyles.HexNumber);
}
File.WriteAllBytes(TARGET, newByteArray);
}
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Excel;
using System.Windows.Forms;
using System.Reflection;
namespace testtesttestExcel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Declare these two variables globally so you can access them from both
//Button1 and Button2.
Microsoft.Office.Interop.Excel.Application objApp;
Microsoft.Office.Interop.Excel._Workbook objBook;
Microsoft.Office.Interop.Excel.Workbooks objBooks;
Microsoft.Office.Interop.Excel.Sheets objSheets;
Microsoft.Office.Interop.Excel._Worksheet objSheet;
Microsoft.Office.Interop.Excel.Range range;
private void button1_Click(object sender, System.EventArgs e)
{
try
{
// Instantiate Excel and start a new workbook.
objApp = new Microsoft.Office.Interop.Excel.Application();
objBooks = objApp.Workbooks;
objBook = objBooks.Add(Missing.Value);
objSheets = objBook.Worksheets;
objSheet = (Microsoft.Office.Interop.Excel._Worksheet)objSheets.get_Item(1);
//Get the range where the starting cell has the address
//m_sStartingCell and its dimensions are m_iNumRows x m_iNumCols.
range = objSheet.get_Range("A1", Missing.Value);
range = range.get_Resize(5, 5);
//Create an array.
double[,] saRet = new double[5, 5];
//Fill the array.
for (long iRow = 0; iRow < 5; iRow++)
{
for (long iCol = 0; iCol < 5; iCol++)
{
//Put a counter in the cell.
saRet[iRow, iCol] = iRow * iCol * iCol;
}
}
//Set the range value to the array.
range.set_Value(Missing.Value, saRet);
objApp.Visible = true;
objApp.UserControl = true;
}
catch( Exception theException )
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat( errorMessage, theException.Message );
errorMessage = String.Concat( errorMessage, " Line: " );
errorMessage = String.Concat( errorMessage, theException.Source );
MessageBox.Show( errorMessage, "Error" );
}
Microsoft.Office.Interop.Excel.Range currentFind = null;
Microsoft.Office.Interop.Excel.Range firstFind = null;
string A = "16";
// You should specify all these parameters every time you call this method,
// since they can be overridden in the user interface.
currentFind = objSheet.Cells.Find(A, Type.Missing,
Microsoft.Office.Interop.Excel.XlFindLookIn.xlValues, Microsoft.Office.Interop.Excel.XlLookAt.xlWhole,
Microsoft.Office.Interop.Excel.XlSearchOrder.xlByRows, Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext, false,
Type.Missing, Type.Missing);
while (currentFind != null)
{
// Keep track of the first range you find.
if (firstFind == null)
{
firstFind = currentFind;
//textBox1.Text = currentFind.get_Address(true, true, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, false, Missing.Value);
}
// If you didn't move to a new range, you are done.
else if (currentFind.get_Address(Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing)
== firstFind.get_Address(Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing))
{
break;
}
currentFind.Font.Color = System.Drawing.ColorTranslator.ToOl
(System.Drawing.Color.Red);
currentFind.Font.Bold = true;
currentFind = objSheet.Cells.FindNext(currentFind);
}
}
}
After finding the cell containing "16", i want to write in string data to the right of it. how should i go about doin this. I did some research on the codes, but i kept getting errors. Please advise me on my problem. Thanks alot!!
modified on Friday, September 11, 2009 11:12 AM
|
|
|
|
|
i'm trying to obtain my hardware information through wmi
but i cant obtain ram manufacture
i think PNPdeviceid field in win32_physical memory must be useful
but its appirience is UPSET
please help me
|
|
|
|
|
Manufacturer property in Win32_PhysicalMemory will return that.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
i knew it
but that field returned no value
|
|
|
|
|
moein.serpico wrote: but that field returned no value
How many machines have you tried it on?
If only 1, have you found any application that does return a value for that machine?
It may be that on that particular machine, it is not defined.
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.”
|
|
|
|
|
yes
its name is everest
i download it from softpedia
please if you know some way
show me
thanks
|
|
|
|
|
Unfortunately I do not know another way.
It is just that I have one PC where the method suggested by d@nish works, and another where it doesn't.
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.”
|
|
|
|
|
|
|
There is nothing that says that a manufacturer of a component MUST supply the information for each field in WMI. There nothing commiting manufacturers to supporting WMI at all, so this is no surprise.
The data comes from the memory itself, probabyl though some port communication, not through WMI. I don't know how to get at it though.
|
|
|
|
|
I am developing an application to play DVD. however When i insert a disk, Windows will automatically try to open that disk either in an explorer window or ask the user what to do with the disk. Then I search in the internet and find two approaches.
The first and simplest is to register the special Windows message "QueryCancelAutoPlay" and simply return 1 when the message is handled. This only works for the current window, and not a background application.
The second approach requires inserting an object that implements the COM interface IQueryCancelAutoPlay COM interface into the Running Object Table.
I used the first one. But sometimes two messages of "QueryCancelAutoPlay" are received and the autoplay window appears again. Here is my code of cancel auto play. Sometimes one message of "QueryCancelAutoPlay" is received and the autoplay window doesn't appear. Sometimes no message of "QueryCancelAutoPlay" is received and the autoplay window appear again.
here is my code of cancel the autoplay window.
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (g_uQueryCancelAutoPlay == 0)
{
g_uQueryCancelAutoPlay = RegisterWindowMessage("QueryCancelAutoPlay");
}
if (g_uQueryCancelAutoPlay != 0 && (uint)msg == g_uQueryCancelAutoPlay)
{
System.Windows.MessageBox.Show("QueryCancelAutoPlay1"); //Sometime it appears twice, sometimes it doesn't appear
return (IntPtr)1;
}
return IntPtr.Zero;
}
|
|
|
|
|
|