|
Thanks for the quick respons Robert.
I probaly should have thrown in the stack trace, caus that might have been helpful. My debugging skills aren't what they should be but they're getting there.
Your post led me right to the source of the problem ... A+, Thank You and yet again I'm humbled
- flip
|
|
|
|
|
|
I would like to make changes to files that are stored in a specific windows directory for my application, and I know that it would require the usage of the foreach loop, but I do not know how to apply the syntax of how to access the files in the directory.
Here is what I think is the correct syntax. Please correct me. The error message is that it "cannot convert type string to System.IO.File".
using System.IO;
dirDirectory = "C:/directorypath/";
foreach (File fileName in Directory.GetFiles(dirDirectory))
{
fileName.
... processing (need to access the properties of each file)
}
Would appreciate assistance in establishing the correct syntax. While I realize that the foreach loop requires a specific file/control to evaluate and a collection of files/controls to follow the IN word, it doesn't seem to work here. It would seem to me that the GetFiles() method is a collection and should work. Why doesn't it?
The typical syntax is:
foreach (Control control in this.Controls)
{
... processing
}
|
|
|
|
|
It doesnt work because Directory.GetFiles return a string array and not a collection of File objects.
You have the following options:
1:
<br />
foreach (string fileName in Directory.GetFiles(dirDirectory)) {<br />
}<br />
2:
<br />
foreach (FileInfo fileInfo in new DirectoryInfo(dirDirectory).GetFiles()) {<br />
}<br />
|
|
|
|
|
Wow!!! Thanks, Robert Rohde. It worked!!! I prefer the second option because it more clearly demonstrates that the files are files and that the directories are directories as opposed to simply strings. I appreciate your assistance.
|
|
|
|
|
how can i use Sqlite with C#?
|
|
|
|
|
Google is your friend:
http://www.google.de/search?hl=de&q=sqlite+.net&btnG=Google-Suche&meta=
|
|
|
|
|
Hello,
do anyone know, how to create an ms installer for application1 when I click a button in an application2.
Please help,
Thank u
|
|
|
|
|
I am using a third party socket component for communication. My program should act as a client and i need to connect multiple hosts using this component. Can anyone suggest how to achieve this in c#.
|
|
|
|
|
We are able to connect and access emails from outlook, using out C# program.
However, we are getting this annoying popup from outlook asking for permissions.
Appreacite if someone could help supress this window.
Thanks in advance.
Srinivas
|
|
|
|
|
You have to use native code (or wrap the native code) for Extended MAPI, which is documented in the MSDN Library[^]. Any MAPI clients cause Outlook to prompt for permission because of malicious code abusing the API. There's no way to circumvent it, otherwise it wouldn't be very secure, would it?
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank you. Appreciate the response. It means we need to move to extended MAPI.
Srinivas
|
|
|
|
|
I have some problems in video broadcast. An error message popup from windows media player - "server not available".
Here are some of my code:
SERVER:
// Create a WMEncoder object.
WMEncoder Encoder = new WMEncoder();
// Retrieve an IWMEncBroadcast object.
IWMEncBroadcast BrdCst = Encoder.Broadcast;
// Set the port number.
BrdCst.set_PortNumber (WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP, 8080);
// Create an IWMEncSourceGroupCollection object.
SrcGrpColl = Encoder.SourceGroupCollection;
// Create an IWMEncSourceGroup object.
SrcGrp = SrcGrpColl.Add("SG_1");
// Create a video and an audio source object.
SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
SrcVid = (IWMEncVideoSource)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
// Specify the path of the source file.
SrcAud.SetInput("C:\\temp/poor_mark.wmv", "", "");
SrcVid.SetInput("C:\\temp/poor_mark.wmv", "", "");
// Choose a profile from the collection.
IWMEncProfileCollection ProColl = Encoder.ProfileCollection;
IWMEncProfile Pro;
for (int i = 0; i < ProColl.Count; i++)
{
Pro = ProColl.Item(i);
//MessageBox.Show(Pro.Name);
if (Pro.Name == "Windows Media Video 8 for Local Area Network (256 Kbps)")
{
SrcGrp.set_Profile(Pro);
break;
}
}
// Start the encoding process
SrcGrp.PrepareToEncode(true);
Encoder.Start();
CLIENT:
Player.URL = "http://144.214.61.5:8080";
What're the problems. Please help.
|
|
|
|
|
I posted this before but it got buried. How would I go about manipulating files at the kernel level? I am trying to incorporate file hiding into a project and I can't seem to find any information on the subject. It would work much like Folder Lock which: "locks files on kernel level, Windows Explorer and even real DOS Mode, Works on Windows 2003/XP/2000/NT/Me/98 and all kinds of disk types like FAT16, FAT32, NTFS."
Here is a screen shot of the program folder and where the actual hidden files are located:
http://oxygine.com/Images/show.png
Can someone at least point me in the right direction?
|
|
|
|
|
Ask in C++ forum and post in MS newsgroups (maybe even the DDK section). File hiding and working with the kernel doesn't have much to do with C# anyway.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Anyone ever come across an algorithm for ensuring that text is always in a readable color distinct from it's background?
It seems simple on the surface but the more I get into it the more I hope I don't have to re-invent the wheel.
In the app I'm working on, people can select any ARGB colour for the background of an appointment element on a calendar as a type of quick STATUS type of thing. Unfortunately they can select black and since the text is black it vanishes. I was thinking of auto-adapting the text color to be readable depending upon the background ARGB but it's not as easy as it sounds.
Any thoughts appreciated.
|
|
|
|
|
|
Some time ago I made the same approach. This one is good except for some grey values.
r:128 g:128 b:128 -> convert -> r:127 g:127 b:127 --- not really much of a difference.
Another apporach is (sometimes also hard to read, but never impossible):
<br />
if (backColor.GetBrightness() > 0.5)<br />
foreColor = Color.Black;<br />
else<br />
foreColor = Color.White;<br />
|
|
|
|
|
What about simply adding up the RGB values and toggling between black and white foreground color depending on a certain threshold?
Something like this:
if (bgColor.R + bgColor.G + bgColor.B < 384)
fgColor = Color.White;
else
fgColor = Color.Black;
You can play with the threshold value or the weights of r,g and b (because the human eye is more sensitive to yellow-green than it is to blue, for example), but even with the very simple approach above I got good results.
mav
|
|
|
|
|
Thanks everyone, great ideas, it turned out to be simpler than my coding addled brain thought at the time.
We experimented with your ideas and this is the final algo.:
static public Color InvertColor(Color col)<br />
{ <br />
int nSourceColor=col.R + col.G + col.B;<br />
<br />
int r = 255 - col.R; <br />
int g = 255 - col.G; <br />
int b = 255 - col.B; <br />
<br />
int nInvertColor=r+g+b;<br />
<br />
Color invert;<br />
if(nSourceColor-nInvertColor< 28)<br />
invert=Color.White;<br />
else<br />
invert = Color.FromArgb(r,g,b); <br />
return invert;<br />
}
28 seemed to be a good threshold to ensure that grays didn't cancel each other out.
|
|
|
|
|
Could you just make PadButton.ImageProgperty reference Pic.Image?
|
|
|
|
|
I am a student developing a small application to make my job of maintening a few hundred staff computers a little easier. Part of the program opens an Internet Explorer window at a specific URL.
The problem I am running into is figuring out how to send a Javascript Command to this particular Internet Explorer Window (the equivalent of clicking a button for this page). I have searched this site and many others with no luck.
Any suggestions?
|
|
|
|
|
That's really vague.
What's sending javascript to a window? What kind of "program" are you talking about? How does your question at all relate to C# - which is what this forum is about.
Please be more verbose if you would like any help.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Sorry for the vagueness, I am writing the program in C#, which is why I'm asking for help in this forum. I have C# create a new instance of Internet Explorer and then want to interact with this instance, by sending it a javascript command.
<br />
public static void openBrowser(string url)<br />
{<br />
object o = null;<br />
<br />
SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorerClass();<br />
IWebBrowserApp wb = (IWebBrowserApp) ie;<br />
wb.Visible = true;<br />
<br />
wb.Navigate(url, ref o, ref o, ref o, ref o);<br />
}<br />
So, in this example, I could open up a page like the Office Updates Page and have it check for updates:
http://office.microsoft.com/search/redir.aspx?AssetID=ES790020331033&Origin=HH011710291033&CTT=5
Now, that page automatically scans, but then requires the user to press the "Agree and Start Installation" Button (equivalent of executing the javascript method StartInstallation()). Is there any way to execute this javascript command inside my program? Something like wb.JavaScript(string command)?
Hopefully that makes more sense
Chris
|
|
|
|
|
No you cannot send JScript (Microsoft's implementation, which is what IE uses) to the document, but you can walk the DOM (document object model) yourself. Reference the Microsoft.mshtml.dll assembly in your project (should've been installed with VS.NET) and cast the AxWebBrowser2 to IHTMLDocument2 , which is defined in the mshtml namespace.
From there it's a matter of casting objects to the interfaces that implement the methods, properties, or events you need. These members are named the same thing as in scripting because they are the objects that are scripted (script is merely an engine for using an object model, both in IE and Mozilla and many other applications).
For documentation on the HTML DOM, see the HTML and DHTML Reference[^] in the MSDN Library. There will be some differences since you'll be using an interop assembly (which proxies calls to the unmanaged COM server that is MSHTML, which the WebBrowser control (Internet Explorer) hosts for HTML rendering, etc.), but you shouldn't have any problems if you're familiar with the HTML DOM.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|