Icons from remote files - file

I have started coding an FTP client application (for fun). I’m trying to represent remotely hosted files with icons. For example, let’s say I’m browsing the root folder of an FTP server (/) and want to display the Backup.zip file with the icon association from that client operating system. On some systems, this may be the windows compression icon and other operating systems this may be WinZip or WinRAR icons.
I have the client browsing local files with the SHGetFileInfo() function. This works great with files that are local, however, this function requires the physical file in order to retrieve the associated icon. So, this will not work with remotely hosted files. I have found some samples of loading icons given a file extension, and this is really where the question comes in... What would be the best strategy to get icons associated to remote files?
Go to the registry every time and look up extension to icon associations
Create 1 byte files with each extension and use the SHGetFileInfo() function for remote files (using local 1 byte files as association for remote files)
Other strategies???
What would a professional software company creating an FTP client do?
Thank you for your time.
-Jessy Houle

I suggest that you don't go to the registry every time: go if you need to, but if you've already been for a given filetype then remember/cache that result (within your program) and reuse it.

Use the procedure here from a previous Stack Overflow question on the same idea and uses the registry instead of an actual file.
How can I get the filetype icon that Windows Explorer shows?

Related

VB.Net Transferring A Windows Form App Onto A USB Stick

I am just wondering how do you transfer a windows form application onto a flash drive because every time I have tried after its transferred I click to open it and an error message displays saying:
"Cannot find the file 'F:\Vending Machine.vb.'
I need to be able to transfer it so when it opens I am able to edit the code and the appearance of the application as I would if I were to just open a new windows form application now.
Thank you
Marcus.
You will need to transfer the entire project/solution to the USB.
Transfering the already compiled .exe should open the latest build of your application. Transferring only a portion of the solution folder and then trying to open the .sln will cause errors on the files you have left out.
Clear your FlashDrive
Copy the entire folder(not the contents) to your flashdrive (C:\Users\Marcus's MPC\Documents\Visual Studio 2010\Projects\Vending Machine)
Attempt to open the .sln
Based on your additional comments it seems you are not moving all of the files the solution needs. If you have files stored in other locations (like My Document) those will need to be reconfigured to work with the solution or you will have to mimic the environment.
I would recommend reconfiguring the project to consolidate any stray files you have.

Use Chrome portable to open a index.html file on the same USB stick for a homepage

IS it at all possible to set the Google homepage to a file located on my USB pen drive?
I can link it though the file path, problem being the drive letter would change depending on the system it is plugged into so a hard coded homepage link wont work.
Im unsure of the syntax to use to make it upen the file -
%USBDRIVE%/Webfiles/index.html
The page is used to help new users navigate the USB pen and get the info/files they require as its aimed as users with next to no IT skills or disabilities
Thanks Guys
You've probably found a solution already, but just come across your question and I recently had the same scenario. I'm assuming you mean on PC.
I solved it as follows:
In the PortableGoogleChrome folder (after portable chrome is setup on the usb drive), there is a default file called parameter.txt. I added the following in order to set the homepage to my local file. It is in a sub folder called 'resources' located on the usb drive root:
--homepage="\resources\index.html"
That's all for the parameter.txt file. That takes care of the homepage setting.
Now to launch portable chrome, I created a windows batch file called launcher.bat also at the root of the usb drive (call it whatever you like obviously!). I added the following code:
#echo off
cd PortableGoogleChrome
"ChromeLoader.exe"
The launcher file changes the directory to PortableGoogleChrome and then loads Chrome via ChromeLoader.exe which takes in your homepage or other parameters in Parameters.txt.
FINALLY, in order to create an application to replace the Launcher.bat file (as I figured a windows application with icon would be more intuitive to run than the batch file), I found a windows utility called bat_to_exe_converter which enabled me to convert the bat to an exe and supply an icon also (having tried to do so in C++, C# but errors because of needing supporting DLL's, this was much more straightforward).
Hope that's of use!

Database errors in Quantum Grid demos in Delphi XE Professional

Whenever I open one of the Quantum Grid demos in Delphi XE Pro (on Windows 7 32-bit), the following error is displayed for every table (I think) in the project:
error message http://www.tranglos.com/img/qgerror.png
The message is:
Network initialization failed.
File or directory does not exist.
File: C:\PDOXUSRS.NET
Permission denied.
Directory: C:\.
I understand permission issues writing to c:\, but the result is that while I can build and run the demo projects, no data is displayed, which makes the demos rather useless. And what kind of database writes its configuration to c:\ directory in the 21st century anyway? :) (Yes, I know very little about Paradox databases, but I won't ever be using one either. I just want to learn how to use the grid.)
Using BDE Administrator I've tried changing the Paradox "NET DIR" value to a folder with write permissions on the C drive. Result: now the database tables cannot find their data:
Path not found.
File: C:..\..\Data\GENRES.DB.
...and the unhelpfully truncated path gives no indication where the files are expected to be.
Is there a way to work around the problem so that the demos can load their sample data correctly?
Did you install the BDE correctly? It should use the DBDEMOS files. Do you see such an alias in the BDE administration utility? Can you open that database in one of the Delphi demos?
The BDE is not a XXI century database, it was developed twenty years ago and never upgraded lately. It's an obsolete tecnology, but because it comes still with every release of Delphi with a known database it is still often used in demos because nothing new has to be installed.
Anyway that file is not its configuration file. It's a sharing lock file to allow more than one user to use the database concurrently. Because it is a file based database without a central server, it has to use such kind of shared files. Usually its position is changed to a network share, but it defaults to C:\ for historical reasons.
Anyway it's not only the BDE still attempting to write in the prong directories. I still see a full bunch of applications attempting to write to C:\ (especially logs) or other read-only positions.
Using BDE Admin to change the location for PDOXUSRS.NET helped, but it wasn't sufficient. DevExpress did the right thing in specifying a relative folder for the data location, and the relative folder seems perfectly allright, but for some reason the DB can't find it.
Solution: under the \Demos\ folder find all the *.dfm files that contain the string
..\..\Data
and replace that string with the absolute path to the demos folder. That done, all the demos open correctly.
I know this message from our own applications. It has to do with security measures introduced with Windows Vista. The operating system trying to protect critical files denies access to them. There is a method how to bypass this mechanism without compromising security. Try to run your application in compatibility mode. When application is running in compatibility mode, read / write operations from / to system folders are redirected to "safe" directories located in C:\Users[Current User]\AppData\Local\VirtualStore.
More info on http://www.windowsecurity.com/articles/Protecting-System-Files-UAC-Virtualization-Part1.html.

Access a local file in Silverlight

I want to get the string from a local file (probably a Csharp file), which is attached to current project and its build action was set to Compile. Is there any way to do that. I cannot set the files' build action into Resource.
Regards,
Jawahar
I'm not clear which of these two questions you're asking:
Question 1) Can I get the text of a source file used during compilation, after compilation?
Answer 1) You'd need to set the build action to Content or Resource to do that, but realize that means you'd be shipping your source with your xap, so make sure that's what you want to do (i.e. most employers probably wouldn't like this).
You can have the file added to the xap twice by using "Add -> Existing Item -> (pick the file) -> Add As Linked Item (the little drop-down arros next to Add buton)" and set one to Compile and one to Content/Resource to accomplish this.
Question 2) Can I access a local file on the hard drive of a user of the Silverlight application?
Answer 2) Yes, by using OpenFileDialog and having the user choose the file.
Or, if you're in a Trusted Out of Browser Application (SL4 and above), then you can use the System.IO APIs to access files in My Documents, My Pictures, My Videos or My Music (on Windows an Mac) without needing to prompt the user.
Or, if you're in a Trusted OOB app, running on Windows, you can use COM and access the full file system (up to what the user can see permission-wise), again without prompt.

Round trip editing of binary documents stored on a server

I'm looking to build some functionality for a content management system for the editing of files stored on the server.
I'd like to provide users the ability to easily download files locally to their computer, open the file for editing, and save it back to the server. The process should be as seamless as possible.
Here's the steps today:
Click the link to download the file (say a PSD) in a web browser
Save it to disk
Find the file, open it for editing in Photoshop
Make changes, save the file
Go back to the browser,navigate to the file that was downloaded.
Click "replace file"
Find the file, upload it back to the server.
Here's what I want:
Click the link to open the PSD file
File is downloaded, Photoshop launches
Make changes, save the file
File is uploaded back to server, replacing the original file
Those who have used Sharepoint know that this works (using WebDAV) but only with the Office applications (PPT, DOC, XLS). I'd like it to work with all file types.
This will take some kind of software to be installed locally - perhaps a separatly installed application with a mime type registered, a signed java applet, or a firefox extension.
This seems like a problem that should have been solved. Has anyone seen this done before?
Windows client OS has a WebDAV redirector and has had for a long time, so
a) you shouldnt need a client piece and b) it's not specific to Office files.
The fun bit is the server end, implementing a WebDAV server.
WebDAV isnt supported on client OSs like Vista (IIS5.1 has support, 6.0 doesnt), only on Servers (2K3, 2K8...)
There is goo/examples/frameworks (cant recall which from when I researched it) available for implementing a WebDAV server, but it requires a server OS [so I had to discount it as the host in my case could potentially have been Vista/7, not server/XP).
The site WebDAV Resources includes a link to at least one open-source server implementation. I haven't used this software, I'm just citing the reference.
It appears that Apache has deprecated or dropped support for server-side WebDAV since the Jakarta Slide project has been retired.

Resources