|
slavakr wrote: it worked without @
Cool.
The double slashes are because the single slash in a string is an escape character, so you can't just have one on it's own. The first escapes the next character.
So in the string "c:\test" the \t will become a tab (see here[^])
So instead it's common to put "c:\\test" which means the first slash just escapes the second and the string will become a correct path.
If you want to have a string without escape characters, you can put the @ sign at the beginning, and it will not use any escape sequences in the string. So @"c:\test" will not escape the t like it would if you missed out the @ sign. So with the @ sign in place, there is no need to use double slashes.
There's more about escape characters on Wikipedia[^]
Simon
|
|
|
|
|
C# newbie here.
I am using the wonderful John’s Background Switcher[^] to keep my wallpaper fresh and interesting, and I realized I'd like to make use of it for my screen saver, too.
Since he does not have an option for that, I thought I'd try learning how to make a little C# screensaver form that just showed the wallpaper as is.
That was about a week ago.
In my experiments, I decided there are two general ways of solving this problem:
1) create a blank desktop and display it with no apps running (or my own app, which wouldn't do anything but listen for a keypress)
2) hide everything on the existing desktop, leaving only the wallpaper visible
I have found code samples for creating desktops, but nothing that I can figure out how to make work with my tiny brain. So I concentrated on option 2.
This requires 3 steps:
a) hide all shortcut icons
b) hide all running taskbar icons [& the taskbar]
c) make wallpaper visible through my app's form
C seemed pretty easy from my Java perspective: just throw up a glasspane and be done. C# begs to differ with me.
I did finally find a way to keep my app transparent enough without allowing click-thru (mouse clicks activating the visible icons behind my transparent form), or so I think. Regardless, it won't matter if I hide everything that shouldn't be shown.
I have just now figured out how to reliably hide shortcut icons and redisplay them at will. This problem was a lot harder than it should have been because everybody seems to say "icons" when they mean the stuff on the taskbar (naturally, I assumed they'd use the term tasks or some such - silly me). But now it's good.
So now I am stuck on step B - hide everything else. I did find a PInvoke for toggling the desktop, but it has some nasty drawbacks:
- it requires including a DLL with the screen saver executable
- it does not let me know if things are visible or not
- the restore does not put things back the way they should be
I really think the first option is best (create an empty desktop), but I don't know how to make that work. If anyone has the right solution...
Barring that, does anyone know how to "properly" hide all desktop icons, and then how to restore them as they were?
No code shown because my stuff is a horrible mess and would only make this post even more confusing. But I'll post whatever bits are requested, and of course when I get it working I'll share the whole finished steaming pile of code.
よろしくおねがいします。
Narf.
|
|
|
|
|
It seems like you are overcomplicating the problem.
I don't understand why you don't just make your app full screen and display the required image over the top of everything else.
Simon
|
|
|
|
|
Well, obviously the big factor here is learning. I'm doing this because I want to know something about C# and Windows APIs and stuff.
But more specifically to your point, because the "required image" changes from time to time. The wallpaper changer automatically pulls down random images from the net.
In order to reproduce all of that functionality, I'd have to do something very complex indeed, and that's definitely beyond the scope of my little project.
My app IS fullscreen, because it has to cover all the other apps and prevent them from receiving keystrokes/mouse movements. I had to make it transparent so I could see the stuff below, but do that without letting the mouse clicks or keystroke slip through.
In Java, that means a glasspane. In C#, it means a headache. At least so far as I know. Total newb here.
Narf.
|
|
|
|
|
|
No, it's Windows that is making my life miserable. I am just trying to learn how to make use of the APIs to do something that, conceptually at least, is very straightforward.
The second link is one I already used. I think it was the third one I found for making C# screen savers. Also, Visual Studio 2005 comes with a screen saver learning kit, and I used that one, too. I know the basics already.
But my only problem now is I want to view the wallpaper - and nothing else - beneath my transparent pane, while still preventing any keystrokes etcetera from getting through.
Technically my problem is not knowing how to do that, but that's why I'm asking for help.
The first link is also interesting, and I may want to look at it later, but it's for a different kind of project than what I am trying to do here. Thanks anyway.
Narf.
|
|
|
|
|
Hello evertbody,
I wanted to know how to find the contents of cache memory in c#.Can anobody give a hint or a code snippet for this problem..
Thanking in advance
Swapnil
|
|
|
|
|
Cross post from different ID ...
Why do you need to create more than one id for you ... ??
|
|
|
|
|
Ya right I want to get contents of computers cache memory..
actually I want to get contents of mozzila's cache memory...
Do you have any Idea?
|
|
|
|
|
I didn't understand your question properly. Are you saying you want to scan Cache and find if the required info has been present?
|
|
|
|
|
Hi,
Actually I am developing a tool to check the performance of a site. so whenever I enter a site I want to know is the contents of the url are present in cache or not and if present want to display the contents. So do you have any idea about it. I want to do this in c#.
|
|
|
|
|
Hi, all,
I am doing with a custom control in WinForms, and there is one customed integer type property, say, currentLine , declared in that custom control class with the following code:
private int currentLine;
public int CurrentLine
{
get { return currentLine; }
set { currentLine = value; }
}
but this property's value should be restricted between 1 and 100.
How to make this happen, so that a value smaller than 1, or bigger than 100 is rejected to be entered in properties window at designer time?
Any suggestions are so much appreciated!! Thanks.
Br!
Sun
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:30am.
|
|
|
|
|
thank you, stancrm,
I've tried this, I added one method, OnCurrentLineChanged() in the SET of that property, and the method is as follows:
private void OnCurrentLineChanged()
{
if (currentLine < 1 || currentLine > 100)
{
throw new System.ArgumentException("Property value is not valid", "original");
}
}
However, I don't know for what reason, it doesn't work when I go designer window and try a number like 123.
Any idea with this?
Br!
Sun
|
|
|
|
|
Hi, stancrm,
You are right. I did this exception in the wrong place, and with a wrong exception name as well . I noticed it after I read Sur's reply.
Anyway, Thank you two!! A lot!
Br!
Sun
|
|
|
|
|
Leapsword Sun wrote: public int CurrentLine
{
get { return currentLine; }
set { currentLine = value; }
}
change this to
public int CurrentLine
{
get { return currentLine; }
set {
if(value < 1 || value > 100) throw new ApplicationException("Invalid Input");
currentLine = value;
}
}
This will throw an exception for invalid values. You can modify this according to your need. Just modify the set portion of CurrentLine
|
|
|
|
|
Hi, Sur,
Thank you so much! This solved my problem. Really, thanks a lot!!
Br!
Sun
|
|
|
|
|
Hello evertbody,
I wanted to know how to find the contents of cache memory in c#.Can anobody give a hint or a code snippet for this problem..
Thanking in advance
Swapnil
|
|
|
|
|
are you talking about HttpContext.Current.Cache ??
Or you mean Computer cache memory ??
|
|
|
|
|
Hi,
I'm writing a code where one file is logging data constantly every 2 seconds , which should be opened by other process which keeps updating the log from file.
I have written code , but it is reading only after the logging file is closed , I would appreciate anyone give me some pointers as how can I open same file in 2 processes.
I have opened file using this parameters;
Program 1:
FileStream fileStream = new FileStream(
@"C:\WINDOWS\system32\Logfiles\MSFTPSVC1\ex091021.log",
FileMode.Append,
FileAccess.Write,
FileShare.ReadWrite);
Thanks,
|
|
|
|
|
|
|
okay,
we know that we can reference third party DLLs in a Visual studio project. But while referencing we need to set copy local=true. So that the referenced dll is copied to the start up path. But i failed to reference a dll that will be located to some other folder. For example my project is in D:\\MyProject. And i want to reference a dll in C:\MyDLLs, without copying the dll to my prjects start up path.
How can i do that? I have tried many approaches like editing the codebase element in app.config file.
|
|
|
|
|
Why do you need to do that ? The whole paradigm of .NET is to copy dlls locally.
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.
|
|
|
|
|
actually i want to place all required dlls to a separate folder other than the application.startup folder. So that while shipping the product all the executables refer to a same directory of dlls. Are there any methods so that i can change the default folder where the dlls are copied instead of start up path?
|
|
|
|