I need to select or read only .config files via file chooser in java fx can any one help me - javafx-2

I need to get the file path of the .config folder only can any one help me

You can add ExtensionFilter to your FileChooser to select only .config files (or any type) via FileChooser.
e.g.
FileChooser flc = new FileChooser();
flc.setTitle("Select File");
ExtensionFilter ext = new ExtensionFilter("Config Files", "*.config");
flc.getExtensionFilters().add(ext);
File tmpFile = flc.showOpenDialog(stage);
You can set any extention type to the FileChooser.
e.g.
ExtensionFilter ext = new ExtensionFilter("Image Files", "*.png", "*.jpg", "*.jpeg");
Hope it helps.!

Related

Looping through a .zip file to open an Excel file, can't get file extension?

I'm trying to loop through a directory with .zip files and pull out the file which is an Excel type file having specific string in the name. I can see the files within .zip having .xlsx extension, but why I try to get this extension name (file_ext) using GetExtensionName, it's empty. Here is a slice of my code:
'Create instance of the shell application
Set obj_app = CreateObject("Shell.Application")
'Get the .zip file
Set obj_file = obj_app.Namespace((str_zip_file)).Items
'Loop through each file within the .zip file
For Each obj_stream In obj_file
str_file = obj_stream.Name
If obj_stream.Type Like "Microsoft Excel Worksheet" And InStr(str_file, "ESG") Then
Set obj_target = obj_app.Namespace(obj_subfolder.Path)
'If it's an Excel file, set the file name to `str_excel_file` and exit the loop
str_excel_file = str_file
obj_target.CopyHere obj_stream
file_ext = LCase(obj_fso.GetExtensionName(obj_subfolder.Path & "\" & str_file))
Exit For
End If
Next obj_stream
Also, when pulled out of .zip into the directory when actual .zip is placed (done by obj_target.CopyHere obj_stream) it appears as being without '.xlsx' extension. What am I doing wrong?

FolderBrowserDialog last Folder Name

I'm new to C++/CLI and have a Question about the FolderBrowserDialog function.
Using ->SelectedPath gives me "C:\Folder\Subfolder\Selected Folder"
How can I save JUST "Selected Folder" to a string?
FolderBrowserDialog^ DestinationFolderDialog;
DestinationFolderDialog = gcnew System::Windows::Forms::FolderBrowserDialog;
System::Windows::Forms::DialogResult result = DestinationFolderDialog->ShowDialog();
if (result == System::Windows::Forms::DialogResult::OK)
{
String^ path = DestinationFolderDialog->SelectedPath;
SetDestinationPath(path);
lblDestinationPath->Text = path;
}
The way I set my Destination Path
And now I want to work with it
String^ pathSource = GetSourcePath();
String^ pathDest = GetDestinationPath();
Im trying to generate Symlinks.
So im Selecting "Y:\Movies\Movie_a" as Source
And im Selecting "X:\" as Destination for my Symlink Folder
To Create it I need to add "Movie_a" to "X:\"
Can someone help me?
If what you want is to extract the last dir name from C:\Folder\Subfolder\Selected Folder then you can:
use Path.GetFileName method to acquire the last part from the path
call String.Split with the Path.PathSeparator and take the last array element
Updated in respect to #LucasTrzesniewski comment

Openfiledialog method alternative in lotus script

Is it possible to get all files (ex : jpg images) from a particular folder with out using openfiledialog method in lotus script? In lotus script, we can give the file path as hard coded.
You can use Dir to get all files from a folder:
Dim pathName As String
Dim fileName As String
pathName = "C:\yourFolder\"
fileName = Dir(pathName + "*.jpg", 0)
Do While fileName <> ""
Print pathName + fileName
fileName = Dir()
Loop
This sample code prints all your jpg files from yourFolder like
C:\yourFolder\a.jpg
C:\yourFolder\b.jpg
C:\yourFolder\c.jpg
From there you can use the list to attach the files to a document or whatever you want to do with the files.
Here you can find the description.

Find path of excel file in dll

I have a dll that needs to open an excel file but i cannot seem to create the path to the file. The excel file is a template that must be used to compare with an excel file that the user will browse for and open.
I have used this code previously when using an exe file for my application:
string path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Data\\BulkMaintenanceExample.xls");
but with a dll it does not seem to work. Any Ideas?
Try following to get the assembly path:
var dir = AppDomain.CurrentDomain.BaseDirectory;
or
//get the full location of the assembly with DaoTests in it
string fullPath = System.Reflection.Assembly.GetAssembly(typeof(DaoTests)).Location;
string theDirectory = Path.GetDirectoryName( fullPath );
or
string filePath = new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath;
return Path.GetDirectoryName(filePath);

How to use TARGETDIR in visual c++?

Currently the path inside my code is hardcoded. I want to make it dynamic, base on the users selected installation path.
How can I use TARGETDIR inside my code here:
SHELLEXECUTEINFO info = {0};
info.cbSize = sizeof(SHELLEXECUTEINFO);
info.fMask = SEE_MASK_NOCLOSEPROCESS;
info.lpFile = _T("C:\\PROGRA~1\\APPY\\IECapt.exe");
info.lpParameters = full;
info.nShow = SW_HIDE;
TARGETDIR is the path to the directory where you .EXE file is linked. And it's only available at compile time. You want to get the installation directory, so TARGETDIR is not useful.
GetModuleFileName() gives you the path, where your .EXE has been loaded.
This is just a suggestion......
You can use one button and in the OnButonClick() function add the below codes with your other codes..........
CFileDialog m_IDFile(TRUE);
m_IDFile1.m_ofn.lpstrInitialDir=L"C:\\PROGRA~1\\APPY\\";
if(m_IDFile1.DoModal()==IDOK)
m_cFileName=m_IDFile1.GetPathName();
info.lpFile = _T(m_cFileName);

Resources