Finding a file path - file

Which method of the File class can I use to return the absolute path of a text file whose name is already mentioned in the application. In other words, the name of the file or its relative path is not to be typed in by the user.

Either e.g. FileInfo.FullName in VB.Net
or I donĀ“t understand the question...

Related

Why is my import statement looking for '.\src\components\Form\Components'

Full error code is:
Cannot find file: 'Form.js' does not match the corresponding name on disk: '.\src\components\Form\Components'.
Attached is a screenshot of my folder setup and App.js file
You need to be careful with file or folder name with its uppercase and lower case, here you need to change '.\src\components\Form\Components' to '.\src\Components\Form\Form' also need to change '.\src\Components\Posts\Posts'.

Logic Apps SharePoint Connector - Move file with new file name

We have a integration requirement to move files from one folder to another in SharePoint Online. The new file name in the destination folder needs to be suffixed with the current datetime. For instance, if the source filename is Myfile.csv, it should be moved with the new name Myfile_2021-04-15T15:39:23.csv to the destination folder.
Using the Logic App SharePoint Move file action, I haven't been able to achieve this
If another file is already there is an enum and I'm unable to provide a custom expression for it. Further, with this option files are only renamed if there's a file with the same name already existing in the destination folder. Whereas our requirement is to attach datetime to all files that are being transferred, independent whether the file already exist in the destination folder or not.
How can I best achieve this?
Thanks in advance for any assistance.
Since the "Move file" action doesn't provide a feature for us to specify the new file name, I think the requirement can't be implemented by this action. You can just use other action to do it.
For example, use "Get file content" action to get the file content.
Then use "Create file" action to create the new file in the location which you want.
You can specify a name which you want in the "File name" input box.
By the way, the "Get file content" action doesn't provide an expression of file name for us to use in second step. But I noticed that you have got Full path in your description, so you can substring the Full path to get the original file name. And then use utcNow() method to get the current date and append it to file name.

How to get folder path runtime

I am new to java.
I am using this code
MyClass.class.getClassLoader().getResourceAsStream("myfile.properties")
to the values from property file.
Now i am storing the webdriver in a folder under project, would like to get the path dybamically, so im using this code:
MyClass.class.getClassLoader().getResourceAsStream("Drivers\\IEDriverServer_x64_2.50.0.zip")
but this returns null, can any one suggest me how to read the file/folder located under the project?
First of all check the location of the file you want to load inside the JAR and try using relative paths like
MyClass.class.getClass().getResourceAsStream("/yourFolder/myfile.properties")
OR
MyClass.getClass().getClassLoader().getResourceAsStream("/yourFolder/myfile.properties")

File property in RollingFileAppender - logback Configuration

I have the following RollingFileappender in my logback configuration file.
<appender name="RollingFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>C:\Files\MyLogFile.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>C:\Files\MyLogFile.%d{yyyy-MM-dd}.log</FileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %logger{60} [%file:%line] %msg%n</pattern>
</encoder>
</appender>
It does write to MyLogFile.log but does not append the date as specified in the FileNamePattern.
There is a simular question, but it never answered my confusion.
I should omit the file property.
Why is the file-property then usefull, because it seems to overrule the rolling-file activity.
This confuses me. Did is get something wrong?
The file property, when used along the fileNamePattern one, will define the name of the ACTIVE file, and only archived files will have that pattern as name. When the active file is rolled, a new archive file will be created with that name. From chapter 4 in the manual:
Note that the file property in RollingFileAppender (the parent of TimeBasedRollingPolicy) can be either set or omitted. By setting the file property of the containing FileAppender, you can decouple the location of the active log file and the location of the archived log files. The current logs will be always targeted at the file specified by the file property. It follows that the name of the currently active log file will not change over time. However, if you choose to omit the file property, then the active file will be computed anew for each period based on the value of fileNamePattern.
So it is useful when you want to have a fixed name, for example, if you need to send the active file programmatically and don't want to guess what the file name would be for the current date.
Also notice that file is a property inherited from the regular FileAppender.

Application design - read data from text file

I am trying to create an app which has a predefined set of data(currently a text file) and it reads from it, now how should i implement the data storage such that when i share the app with someone else, i don't have to pass the text file or any other data file(if possible, i can encrypt the contents and give it using a different extension) externally. I just want to give one exe file to the person and the data should be included inside the exe.
anyway to do it ??
Thanks in advance
Include the text file as a resource.
You do not need to change the build (if you are using Visual Studio that is). Visual Studio will embed the resource/file and generate a readonly property for the file so you can access it directly from within your code:
string fileContent = YourResourceFile.TheEmbeddedFile;
You could split the fileConent per linebreak but the previous line will load the entire file into memory.
string[] lines = fileContent.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
If the file is too big to be read into memory at once, you could stream the resource as explained here.
You can change the build mode of the file to resource/embedded resource, reading from it works different then, this should be answered somewhere though.

Resources