convert a file object into a string - meson-build

In a meson.build file, I have some file define by :
file = files("my_filename.ext")
To build an ID, I have try to write :
myTgt = "_other_ext" + file[0][0]
And then I have this error :
meson.build:257:4: ERROR: Invalid use of addition: must be str, not File
How can I convert the file object into a valid string ?
(I have try to add .string(), but it's not the solution)

I have found solution with format function:
fmt = "_other_ext_#0#"
myTgt = fmt.format(file[0][0])

Related

as for 'replace' usage, does it support to replace the placeholder with value in place (I mean "over-write"))?

I need to upload a file to the server side, however, before doing that I need to replace a placeholder in the file with a dynamic value. does it support to get the placeholder replaced in place dynamically?
I noticed that I can replace the placeholder with ease using the 'replace' keyword. The following is my script:
Given path 'common/upload'
And multipart fields read('classpath:mainFlow/labresultUpload.json')
* def filename = 'PKU.A22backup'
* def someString = read('PKU.A22backup')
* print someString
* replace someString
|token|value|
|labsampleid|'123456'|
* print someString
* multipart file file = { read: "#(filename)", filename: "#(filename)"}
When method post
Then status 200
* def result = response[0].result
However, I need to replace the placeholder in place (here, I mean over-write) dynamically and then upload the file to the server side.
You have the option to supply a value instead of the file-name: https://github.com/intuit/karate#multipart-file
* multipart file file = { value: "#(someString)", filename: "#(filename)" }

Get only file name from openfiledialog [duplicate]

I am using the following method to browse for a file:
OpenFileDialog.ShowDialog()
PictureNameTextEdit.Text = OpenFileDialog.FileName
Is there a way get ONLY the file name?
The FileName method returns the entire path and file name.
i.e. I want Foo.txt instead of C:\SomeDirectory\Foo.txt
Use Path.GetFileName(fullPath) to get just the filename part, like this:
OpenFileDialog.ShowDialog()
PictureNameTextEdit.Text = System.IO.Path.GetFileName(OpenFileDialog.FileName)
OpenFileDialog.ShowDialog()
PictureNameTextEdit.Text = System.IO.Path.GetFileName(OpenFileDialog.FileName)
C++ code for obtain filename and complete path in OpenFileDialog:
textBox1->Text = OpenFileDialog1->FileName; //complete path
textBox1->Text = System::IO::Path::GetFileName(OpenFileDialog1->FileName); //filename
Suppose that I did select word2010 file named as "MyFileName.docx"
This is for ONLY the selected file extension "including the dot mark, f.e (.docx)"
MsgBox(System.IO.Path.GetExtension(Opendlg.FileName))
And this for the selected File name without extension: (MyFileName)
MsgBox(System.IO.Path.GetFileNameWithoutExtension(Opendlg.FileName))
and you can try the other options for the "PATH Class" like: GetFullPath,GetDirectoryName ...and so on.
if you want just the selected name without Extension you can try this code
Imports System.IO
PictureNameTextEdit.Text = Path.GetFileNameWithoutExtension(OpenFileDialog1.Fi‌​leName)
thanx
//Following code return file name only
string[] FileFullPath;
string FileName;
objOpenFileDialog.Title = "Select Center Logo";
objOpenFileDialog.ShowDialog();
FileFullPath = objOpenFileDialog.FileNames[0].ToString().Split('\\');
FileName = FileFullPath[FileFullPath.Length - 1]; //return only File Name
//Use following code if u want save other folder ,
// following code save file to CenterLogo folder which inside bin folder//
System.IO.File.Copy(OFD.FileName, Application.StartupPath +
"/CenterLogo/" + FileName, true);
Use SafeFileName instead of FileName and it will return a name (and extension) without path.
Use this code to put the filename in PictureNameTextEdit:
OpenFileDialog.ShowDialog()
PictureNameTextEdit.Text = OpenFileDialog.SafeFileName

How to read conf.properties file?

I want to read conf.properties file but but not by giving a hard coded path, so how can I fins it? I have use the below line but its written a null value but the path was correct.
InputStream inputStream = ReadPropertyFile.class.getResourceAsStream("configuration/conf.properties");
Assuming you have configuration folder in your project & that folder contains conf.properties
Use following in your function -
String projdir = System.getProperty("user.dir");
String propfilepath = projdir+"\\config\\"+"conf.properties";
Properties p = new Properties();
p.load(new FileInputStream(propfilepath ));
String value = p.getProperty("test");
System.out.println(value); // It is returning me a value corresponding to key "test"

compressing the file using SevenZipSharp.dll

I want to compress and move the file using vb.net and SevenZipSharp.dll
c:\Backup\FULLBackup.bak -> c:\Archive\20130322.7z
I added a reference SevenZipSharp.dll
Imports SevenZip
SevenZip.SevenZipCompressor.SetLibraryPath(System.AppDomain.CurrentDomain.BaseDirectory & "\SevenZipSharp.dll")
Dim theCompressor As New SevenZipCompressor()
With theCompressor
.ArchiveFormat = OutArchiveFormat.SevenZip
.CompressionMode = CompressionMode.Create
.CompressionMethod = CompressionMethod.Default
.DirectoryStructure = False
.CompressionLevel = CompressionLevel.Normal
End With
theCompressor.CompressFilesEncrypted("c:\Archive\20130322.7z","c:\Backup\FULLBackup.bak")
I get an error : Can not load 7-zip library or internal COM error! Message: library is invalid.
I think it's simply the fact that the LibraryPath must not point to "SevenZipSharp.dll" but to "7z.dll".
http://blog.jongallant.com/2011/10/7-zip-dll-file-does-not-exist.html#.UaOLk0DxobA

Return FileName Only when using OpenFileDialog

I am using the following method to browse for a file:
OpenFileDialog.ShowDialog()
PictureNameTextEdit.Text = OpenFileDialog.FileName
Is there a way get ONLY the file name?
The FileName method returns the entire path and file name.
i.e. I want Foo.txt instead of C:\SomeDirectory\Foo.txt
Use Path.GetFileName(fullPath) to get just the filename part, like this:
OpenFileDialog.ShowDialog()
PictureNameTextEdit.Text = System.IO.Path.GetFileName(OpenFileDialog.FileName)
OpenFileDialog.ShowDialog()
PictureNameTextEdit.Text = System.IO.Path.GetFileName(OpenFileDialog.FileName)
C++ code for obtain filename and complete path in OpenFileDialog:
textBox1->Text = OpenFileDialog1->FileName; //complete path
textBox1->Text = System::IO::Path::GetFileName(OpenFileDialog1->FileName); //filename
Suppose that I did select word2010 file named as "MyFileName.docx"
This is for ONLY the selected file extension "including the dot mark, f.e (.docx)"
MsgBox(System.IO.Path.GetExtension(Opendlg.FileName))
And this for the selected File name without extension: (MyFileName)
MsgBox(System.IO.Path.GetFileNameWithoutExtension(Opendlg.FileName))
and you can try the other options for the "PATH Class" like: GetFullPath,GetDirectoryName ...and so on.
if you want just the selected name without Extension you can try this code
Imports System.IO
PictureNameTextEdit.Text = Path.GetFileNameWithoutExtension(OpenFileDialog1.Fi‌​leName)
thanx
//Following code return file name only
string[] FileFullPath;
string FileName;
objOpenFileDialog.Title = "Select Center Logo";
objOpenFileDialog.ShowDialog();
FileFullPath = objOpenFileDialog.FileNames[0].ToString().Split('\\');
FileName = FileFullPath[FileFullPath.Length - 1]; //return only File Name
//Use following code if u want save other folder ,
// following code save file to CenterLogo folder which inside bin folder//
System.IO.File.Copy(OFD.FileName, Application.StartupPath +
"/CenterLogo/" + FileName, true);
Use SafeFileName instead of FileName and it will return a name (and extension) without path.
Use this code to put the filename in PictureNameTextEdit:
OpenFileDialog.ShowDialog()
PictureNameTextEdit.Text = OpenFileDialog.SafeFileName