delphi DirectoryListBox Get selected directory name - directory

I'm using a dirListBox in delphi. I cant get the sub directory name of the directory selected. It gives me the root direct name instead. How do I get the selected directory name?

dirListBox.Directory returns the parent directory, not subdirectory.
The only way I could get the correct names was using the itemindex.
The itemindex is updated when you click or move the cursor to the directory.
fMain.eProject.Text:=fProject.dirlistBox.Items[fProject.dirListBox.ItemIndex];
fMain.ePath.Text:=fProject.dirListBox.GetItemPath(fProject.dirListBox.ItemIndex);

Related

How can i overwrite file when use move action whether file exist same name in alfresco?

I moved file to another folder if file exist with that name it 's raise error "file already exist". How can i overwrite it to the exist one using move action?
Here is example of same whatever you want to achive but different way.
Might be you will get some idea from that.
https://github.com/keensoft/alfresco-version-by-name

QT How Keep the previous user selected image path in memory for instant loading using QFileDialog

I am working on a program that takes a file from a directory and when I again try to select the path it will not show the same directory. So, I need to fix the previous path when I choose the next path it will select the previous path.
The first time I will select this path
Example:- C:\Work\Projects\GDCM\gdcm-2.8.6
Next time I will again click to take a file from the same path but it will show the by default path.
Example:- C:\Program Files (x86)
I am using QFileDialog for selecting the path:-
QString dir = "";
QFileDialog dia;
dir = dia.getExistingDirectory(this, tr("Select DICOM Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
dia.setDirectory(dir);
The third parameter of QFileDialog::getExistingDirectory specifies the initial directory used by the dialog, and you are not using it correctly.
You are clearly using Windows yet you are always setting the initial directory to a unix home directory /home. Rather initialise your string variable and reuse it in subsequent calls.
QFileDialog dia;
dir = dia.getExistingDirectory(this, tr("Select DICOM Directory"), dir, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
Store the return value of dir and reuse it the next time you invoke the dialog for the third parameter. You don't need to be using setDirectory.

ASP.NET Directory.GetParent seems to be returning the actual folder path, not the parent path

I want to get the parent directory path of my solution's startup project, by testing that code
string parent = System.IO.Directory.GetParent(Server.MapPath("~/"));
I get the directory where my solution's startup project is currently placed. Why ?
I am not sure why this happens, at the momemt. But you can do
string parent = new DirectoryInfo(Server.MapPath("~/")).Parent.FullName;
to get the parent directory path.
I try to find a answer why System.IO.Directory.GetParent(Server.MapPath("~/")) does not work and update this if i found something.
Update
I found a possible answer on another Stackoverflow question who GSerg say
I can only assume Directory.GetParent(...) can't assume that C:\parent\child is a directory instead of a file with no file extension. DirectoryInfo can, because you're constructing the object that way.
The reason this is happening is because Server.MapPath is appending a \ at the end of the path (even if you remove it from your MapPath), for example:
C:\foo\bar\
If you try to get the parent directory of that, it will give C:\foo\bar without the slash.
So this will work:
var path = System.IO.Directory.GetParent(Server.MapPath("~").TrimEnd('\\'));
Here is an alternative:
var path = new System.IO.DirectoryInfo(Server.MapPath("~")).Parent.FullName;

Creating group in Xcode does not create folder in file system -- why?

In Xcode IDE when I add a new group named 'Organizer' inside the default Classes group it is getting created. But when I physically see the folder in the Finder, that new group Organizer is not showing as a folder.
Actually I want to maintain the sources in a particular structure i.e, how it exists in the XCode view.
What should I do to achieve this?
You should create all necessary folders within Finder and then add them to project (right mouse click -> Add files to XYZ project). While adding files, options should look like this:
UPD: Xcode 9 finally supports automatic folder creation and file reordering for groups operations!
If you are adding a new group named Organizer inside the default classes group you cant see the physical folder in finder. To make physical folder you should do following steps,
1. Prepare folder structure with files in it.
2. Drag that folder into xcode i.e. project navigation pan.
3. Check the box " Copy items into destination group's folder (if needed) "
4. Select " Create groups for any added folders "
After doing this, you will get your folder in finder. Now if you want to add new file then just
1. Right click on folder and click " Add files to < Project_Name >"
2. Select proper file
3. Check the box " Copy items into destination group's folder (if needed) "
4. Select " Create groups for any added folders "
5. Finally click to add
You will get that folder with new file added into that.
Note : Keep in mind you get yellow colored folder.
Thank You.

Server.MapPath() not getting the path needed

I have a asp.net website that has the following directory:
C:\Users\Desktop\Testing\src\website
I have another folder called "files" that is here:
C:\Users\Desktop\Testing\src\files
from inside my project i am trying to read files from the "files" folder, i am doing it like this:
var path = HttpContext.Current.Server.MapPath("/files");
I also tried :
var path = HttpContext.Current.Server.MapPath("..");
But it says Failed to map the path '/files'.
What could be the reason for this? could it do something with my IIS? How can i get this working??
Thank you!
You can't do this. The Server.MapPath method only works with folders relative to the root of the web application which in your case is C:\Users\Desktop\Testing\src\website. You cannot go one level up in the hierarchy using this method as you are leaving the domain of control of this ASP.NET application. To achieve this you will have to use an absolute path. For example if you want to read some file which is situated outside of your application:
var data = File.ReadAllText(#"C:\Users\Desktop\Testing\src\files\somefile.txt");
assuming the websites's virtual directory is mapped to .../src/website you need to get "files" folder like this:
var filesDir = Path.Combine(HttpContext.Current.Server.MapPath("~"), "../files/");

Resources