|
Tengo el mismo problema, estoy probando con enviar con puerto 25 y clienteSmtp.EnableSsl = false;
Yo verifico antes que tenga conexion de internet.
|
|
|
|
|
Hi every body
i want to write a program to control one of my windows drives, for example i want to know when and by who (windows user), it is clicked.
i think that, there should be a windows service to control it, but i do not know the way to install a service and the registry key(s) which i should work with.
thanks
|
|
|
|
|
Hi friends
there is nobody to know this? i really want to understand the answer
|
|
|
|
|
amiralimadadi wrote: control one of my windows drives
I do not understand "windows drives"...
amiralimadadi wrote: when and by who (windows user), it is clicked.
U mean to trace the mouse actions?
I Love KongFu~
|
|
|
|
|
yes, i mean the hard drives.
|
|
|
|
|
there is no one who know this!!??
|
|
|
|
|
hi friends...
am stored graphic objects(such as line,rectanle etc...)in arraylist..so now i want to paste the graphic object to screen...please help me..
|
|
|
|
|
Please check this article:
<a href="http://www.codeproject.com/KB/cs/copycustomclasstoclipbrd.aspx">http://www.codeproject.com/KB/cs/copycustomclasstoclipbrd.aspx</a>[<a href="http://www.codeproject.com/KB/cs/copycustomclasstoclipbrd.aspx" target="_blank" title="New Window">^</a>]
Natza Mitzi
|
|
|
|
|
|
Hi.
I'm making an application and have a lot of problems.
First of all, i had trouble figuring out - how to get all the items to lower case.
Ok, i fixed that... but the program doesnt work the way it should.
So, the program should work this way:
You start the app. Then u click the button to get all the files from directory and all subdirectories. This goes ok. Ok, but then, i want to remove all doubles in the list.
If theres a file "BeBack.JPG" the app. should check if there's also "BeBack.PDF" or if theres "BlackWhite.PDF" and "BlackWhite_1.PDF" it should remove both entries from the listbox.
My code doesnt do that i dont know why It also deosnt remove all .gif files
Where did i go wrong? Please help?
Here's the code:
private void button1_Click(object sender, EventArgs e)
{
string[] fajli = Directory.GetFiles(Application.StartupPath,"*.*",SearchOption.AllDirectories);
string[] VsiFajli = Array.ConvertAll<string,>(fajli, delegate(string s) { return s.ToLower(); });
listBox1.Items.AddRange(VsiFajli);
for (int i = 0; i < listBox1.Items.Count; i++)
{
if (listBox1.Items[i].ToString() == listBox1.Items[i].ToString().Remove(listBox1.Items[i].ToString().Length - 4, 4) + ".pdf")
{
if (File.Exists(listBox1.Items[i].ToString().Remove(listBox1.Items[i].ToString().Length - 4,4) + "_1.pdf"))
{
string temp = listBox1.Items[i].ToString();
listBox1.Items.Remove(temp);
listBox1.Items.Remove(temp.Remove(temp.Length - 4,4) + "_1.pdf");
}
}
else
{
if (File.Exists(listBox1.Items[i].ToString().Remove(listBox1.Items[i].ToString().Length - 4,4) + ".pdf"))
{
string temp = listBox1.Items[i].ToString();
listBox1.Items.Remove(temp);
listBox1.Items.Remove(temp.Remove(temp.Length - 4,4) + ".pdf");
listBox1.Items.Remove(temp.Remove(temp.Length - 4, 4) + "_1.pdf");
}
}
}
MessageBox.Show("Done!");
}
private void listBox1_DoubleClick(object sender, EventArgs e)
{
if(listBox1.SelectedItem!=null)
System.Diagnostics.Process.Start(listBox1.SelectedItem.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
if(listBox1.Items.Count != 0)
for (int j = 0; j < listBox1.Items.Count; j++)
{
if(listBox1.Items[j].ToString() == (listBox1.Items[j].ToString().Remove(listBox1.Items[j].ToString().Length-4,4) + ".gif"))
listBox1.Items.RemoveAt(j);
}
}
private void button3_Click(object sender, EventArgs e)
{
if (listBox1.SelectedItem != null)
Clipboard.SetText(listBox1.SelectedItem.ToString()) ;
}
Thanks in advance.
Regards,
Matjaž
modified on Sunday, February 1, 2009 7:30 AM
|
|
|
|
|
The code is almost unreadable, please use the <pre> tags and use proper temporary variables instead of calling listBox1.Items[j].ToString() and others a hundred times. Also, did you know there's a EndsWith method?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Not until now, i didnt know about ends with. Thank you.
Anyway... yes, the code is a mess here in CP... but still, can sombody give me a clue for a better algorythm or something?
Regards,
Matjaž
|
|
|
|
|
Perhaps you can make a tiny demo and debug the code. That will be faster to find out the problem.
I Love KongFu~
|
|
|
|
|
i want to check my modem status every 5 mints.can somebody help with a c# code for that.
|
|
|
|
|
You can use timer object to run method every 5 minutes. As for modem what do you mean by checking it? You can send at commands to the modem.
|
|
|
|
|
i want to check mdoem status..status means..i heva lots of AT commands and i want to execute the methos which has all these commands evry 5 mints...can u help me with c#
|
|
|
|
|
You can check current System DateTime and every 5 minutes run your application.
Another way to do this is with a Windows Service.
Best Regards.
|
|
|
|
|
So what's wrong with my first reply? Use timer classes available in .Net Framework to run code every five minutes and use SerialPort class for sending at commands and reading responses.
|
|
|
|
|
Possibly a Windows Service, but a Windows Scheduled Task would be simpler.
|
|
|
|
|
Hi all!
Continuing my serial port fight ...
This time, i'm trying to make sequential Gsm Calls to diferent Gsm numbers. I'm doing some tests, but something's wrong.
My first dial connection is working fine, but when i close it and try to make the next connection, my application turns blocked... and i can't make other dial... Someone could help me with this? The use of filesystemwatcher is only for test purposes.
The code i'm using is here:
public bool GsmConnected;
public bool GsmConnected2;
public Form1()
{
InitializeComponent();
FileInfo finfo = new FileInfo("C:\\Users\\AJorge\\Desktop\\GsmStatus.txt");
StreamWriter ff = finfo.CreateText();
ff.Close();
InitComPort();
this.Show();
aux_function();
}
private void InitComPort()
{
axMSComm1.CommPort = 4;
if (axMSComm1.PortOpen)
axMSComm1.PortOpen = false;
axMSComm1.RThreshold = 1;
axMSComm1.Settings = "115200,n,8,1";
axMSComm1.DTREnable = true;
axMSComm1.RTSEnable = true;
axMSComm1.CDTimeout = 10000;
axMSComm1.Handshaking = MSCommLib.HandshakeConstants.comNone;
axMSComm1.InputMode = MSCommLib.InputModeConstants.comInputModeBinary;
axMSComm1.InputLen = 0;
axMSComm1.NullDiscard = false;
axMSComm1.OnComm += new System.EventHandler(this.axMSComm1_OnComm);
try
{
axMSComm1.PortOpen = true;
}
catch (Exception e)
{
richTextBox1.AppendText(e.ToString());
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void CheckGsmStatus(object sender, FileSystemEventArgs e)
{
StreamReader fileReader = new StreamReader("C:\\Users\\AJorge\\Desktop\\GsmStatus.txt");
string ReadAll = fileReader.ReadToEnd();
string[] ReadAll_Array = ReadAll.Split(new char[] { ' ' });
for (int i = 0; i < ReadAll_Array.Length; i++)
{
if (ReadAll_Array[i] == "13" && ReadAll_Array[i + 1] == "10" && ReadAll_Array[i + 2] == "67" && ReadAll_Array[i + 3] == "79" && ReadAll_Array[i + 4] == "78" && ReadAll_Array[i + 5] == "78" && ReadAll_Array[i + 6] == "69" && ReadAll_Array[i + 7] == "67" && ReadAll_Array[i + 8] == "84" && ReadAll_Array[i + 9] == "32" && ReadAll_Array[i + 10] == "57" && ReadAll_Array[i + 11] == "54" && ReadAll_Array[i + 12] == "48" && ReadAll_Array[i + 13] == "48" && ReadAll_Array[i + 14] == "13" && ReadAll_Array[i + 15] == "10")
GsmConnected = true;
else if (ReadAll_Array[i] == "13" && ReadAll_Array[i + 1] == "10" && ReadAll_Array[i + 2] == "78" && ReadAll_Array[i + 3] == "79" && ReadAll_Array[i + 4] == "32" && ReadAll_Array[i + 5] == "67" && ReadAll_Array[i + 6] == "65" && ReadAll_Array[i + 7] == "82" && ReadAll_Array[i + 8] == "82" && ReadAll_Array[i + 9] == "73" && ReadAll_Array[i + 10] == "69" && ReadAll_Array[i + 11] == "82" && ReadAll_Array[i + 12] == "13" && ReadAll_Array[i + 13] == "10")
this.Close();
}
fileReader.Close();
}
private void CheckGsmStatus2(object sender, FileSystemEventArgs e)
{
StreamReader fileReader = new StreamReader("C:\\Users\\AJorge\\Desktop\\GsmStatus.txt");
string ReadAll = fileReader.ReadToEnd();
string[] ReadAll_Array = ReadAll.Split(new char[] { ' ' });
for (int i = 0; i < ReadAll_Array.Length; i++)
{
if (ReadAll_Array[i] == "13" && ReadAll_Array[i + 1] == "10" && ReadAll_Array[i + 2] == "67" && ReadAll_Array[i + 3] == "79" && ReadAll_Array[i + 4] == "78" && ReadAll_Array[i + 5] == "78" && ReadAll_Array[i + 6] == "69" && ReadAll_Array[i + 7] == "67" && ReadAll_Array[i + 8] == "84" && ReadAll_Array[i + 9] == "32" && ReadAll_Array[i + 10] == "57" && ReadAll_Array[i + 11] == "54" && ReadAll_Array[i + 12] == "48" && ReadAll_Array[i + 13] == "48" && ReadAll_Array[i + 14] == "13" && ReadAll_Array[i + 15] == "10")
GsmConnected2 = true;
if (ReadAll_Array[i] == "13" && ReadAll_Array[i + 1] == "10" && ReadAll_Array[i + 2] == "78" && ReadAll_Array[i + 3] == "79" && ReadAll_Array[i + 4] == "32" && ReadAll_Array[i + 5] == "67" && ReadAll_Array[i + 6] == "65" && ReadAll_Array[i + 7] == "82" && ReadAll_Array[i + 8] == "82" && ReadAll_Array[i + 9] == "73" && ReadAll_Array[i + 10] == "69" && ReadAll_Array[i + 11] == "82" && ReadAll_Array[i + 12] == "13" && ReadAll_Array[i + 13] == "10")
this.Close();
}
fileReader.Close();
}
private void aux_function()
{
try
{
GsmConnected = false;
if (!axMSComm1.PortOpen)
axMSComm1.PortOpen = true;
axMSComm1.Output = "ATD" + "GsmNumber1" + "\r\n";
}
catch (Exception er7)
{
richTextBox1.AppendText(er7.ToString());
}
richTextBox1.AppendText("Dialing with " + "GsmNumber1" + "...");
fileSystemWatcher1.Path = "C:\\Users\\AJorge\\Desktop\\";
fileSystemWatcher1.Filter = "GsmStatus.txt";
fileSystemWatcher1.NotifyFilter = NotifyFilters.LastWrite;
fileSystemWatcher1.Changed += new FileSystemEventHandler(CheckGsmStatus);
fileSystemWatcher1.EnableRaisingEvents = true;
do
{
Application.DoEvents();
} while (!GsmConnected);
fileSystemWatcher1.EnableRaisingEvents = false;
axMSComm1.Output = "+++\r\n";
axMSComm1.Output = "ATH0\r\n";
Thread.Sleep(2000);
axMSComm1.PortOpen = false;
Thread.Sleep(2000);
InitComPort();
File.Delete("C:\\Users\\AJorge\\Desktop\\GsmStatus.txt");
FileInfo f12 = new FileInfo("C:\\Users\\AJorge\\Desktop\\GsmStatus.txt");
StreamWriter xpto2 = f12.CreateText();
xpto2.Close();
DateTime Begins = DateTime.Now;
DateTime Stops = new DateTime();
do
{
Application.DoEvents();
Stops = DateTime.Now;
} while (Stops.Second - Begins.Second != 10);
try
{
GsmConnected2 = false;
if (!axMSComm1.PortOpen)
axMSComm1.PortOpen = true;
axMSComm1.Output = "ATD" + "GsmNumber2" + "\r\n";
}
catch (Exception er7)
{
richTextBox1.AppendText(er7.ToString());
}
richTextBox1.AppendText("\nDialing with " + "GsmNumber2" + "...");
fileSystemWatcher1.Path = "C:\\Users\\AJorge\\Desktop\\";
fileSystemWatcher1.Filter = "GsmStatus.txt";
fileSystemWatcher1.NotifyFilter = NotifyFilters.LastWrite;
fileSystemWatcher1.Changed += new FileSystemEventHandler(CheckGsmStatus2);
fileSystemWatcher1.EnableRaisingEvents = true;
do
{
Application.DoEvents();
} while (!GsmConnected2);
fileSystemWatcher1.EnableRaisingEvents = false;
axMSComm1.Output = "+++\r\n";
axMSComm1.Output = "ATH0\r\n";
}
private void axMSComm1_OnComm(object sender, EventArgs e)
{
switch (axMSComm1.CommEvent)
{
case ((short)MSCommLib.OnCommConstants.comEvReceive):
byte[] b1 = (byte[])axMSComm1.Input;
FileInfo finfo = new FileInfo("C:\\Users\\AJorge\\Desktop\\GsmStatus.txt");
StreamWriter ff = finfo.AppendText();
for (int x = 0; x < b1.Length; x++)
{
richTextBox1.AppendText(b1[x].ToString());
ff.Write("{0} ", b1[x]);
}
ff.Close();
break;
case ((short)MSCommLib.OnCommConstants.comEvCD):
if (!axMSComm1.CDHolding)
{
richTextBox1.Clear();
richTextBox1.AppendText("Hanging up...");
try
{
axMSComm1.Output = "+++\r\n";
}
catch (Exception e11)
{
richTextBox1.AppendText(e11.ToString());
}
try
{
axMSComm1.Output = "ATH0\r\n";
}
catch (Exception e12)
{
richTextBox1.AppendText(e12.ToString());
}
richTextBox1.AppendText("Disconnected.");
}
break;
}
}
Best regards.
|
|
|
|
|
Hi,
Reposting is bad, but problem is urgent. Sorry for that !
I have a Web Application which referes to COM components for various reasons.
These COM components are built in VB6 and works fine when executed from Windows application from my machine.
This means, COM components are properly registered on my machine. When I gave reference to these from my Web App, respective Interop. DLL are created.
The COM component is the described as - "Microsoft VBUpgrade Tool TypeLib Visual Basic runtime objects and procedures" in VS.NET 2008 reference properties.
Question : I am getting following error when I try to create an object of VBRUN.PropertyBagClass
Error Message : An exception of type System.Runtime.InteropServices.COMException was raised and caught.<br />
Message: Retrieving the COM class factory for component with CLSID {D5DE8D20-5176-4EF2-8581-7B534D2AC56E} failed due to the following error: 80040154.
Stack Trace pointed to the line where object was being created
I searched google and came to a conclusion that I need to give rights of COM component execution for ASPNET account. I tried DCOM Configuration but am not sure to whom give the access rights and of what ?
It would be great if you guys give some sort of pointer to this ? Also wanted to make sure that my conclusion is right ?
Thanks !
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
hi
I have some prom problem with spliting mp3 file.
how can i split this type of file that work properly after spliting ?
I Want Learn
|
|
|
|
|
You need to write headers in both halves. It's best to use DirectX for this, not do it manually.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Search BinaryReader and BinaryWriter in MSDN.
I Love KongFu~
|
|
|
|
|
when a method is called i want to get first index value from an arraylist and when the same method is called next time i want to get the second index value from the same arraylist...how can i do that?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace roseapp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public ArrayList MPN = new ArrayList();
public string[,] Modems = new string[,]
{
{"Apple", "Banana", "81563840", "Damson"},
{"Elderberry", "Fig", "81547907", "Huckleberry"},
{"Indian Prune", "Jujube", "98764343322", "Lime"}
};
public string arrayValue;
private void button1_Click_1(object sender, EventArgs e)
{
// getphnum();
RoundRobin();
}
private int z = 0;
public void RoundRobin()
{
if (Modems == null)
throw new ArgumentNullException("Modem");
if (Modems.Length < 0)
return;
//int Count = 0;
int i;
int x = Modems.Length/4;
MessageBox.Show(Convert.ToString(x));
for (i = 0; i < x; i++)
{
string a = Modems[i, 2];
MessageBox.Show(a);
arrayValue = a;
MPN.Add(arrayValue);
}
for (int a = 0; a < MPN.Count; a++)
{
MessageBox.Show("ARRAY VALUE for index "+a+" "+Convert.ToString(MPN[a]));
}
}
public void getphnum()
{
z++;
MessageBox.Show(Convert.ToString(z));
}
}
}
in this when the getphnum() is called one time i wnat to get firts index value(ie index 0 ph number)ie MPN arraylist.ANd when next time when getphnum () is called i want to get index 1 value from arraylist MPN.(ie the same arraylist from which i call my first array index value)..
can somebody help meeeeeeeeeeee
|
|
|
|