DHTML Scheduler .NET change path script and style files - vb.net

I started experimenting with DHTMLX Scheduler .Net but encountered some 'issues'.
I like to have everything ordered at my own way (css files in folder 'styling', js files in folder 'scripts', ...)
But now it seems like using this dll forces me to place everything in a folder that they chose. So when I init the Scheduler on my page, it automatically tries to call this files:
/Scripts/dhtmlxScheduler/dhtmlxscheduler.js
/Scripts/dhtmlxScheduler/dhtmlxscheduler.css
/Scripts/dhtmlxScheduler/locale/locale_nl.js
I would like to change these paths to for example '/scripts/dhtmlxscheduler.js' but I can't find a property in the Scheduler object where I'm able to do this.
Is this possible or do I have to put everything in the folder they would like to have it?
My working code thisfar:
Public Scheduler As DHXScheduler
Scheduler = New DHXScheduler()
Scheduler.InitialDate = New DateTime(Now.Year, Now.Month, Now.Day)
Scheduler.InitialView = "day"
Scheduler.Config.first_hour = 6
Scheduler.Config.last_hour = 20
Scheduler.Config.time_step = 30
Scheduler.Config.limit_time_select = True
Scheduler.Localization.Set(SchedulerLocalization.Localizations.Dutch)
Scheduler.DataAction = Me.ResolveUrl("/Handlers/Scheduler_Data.ashx")
Scheduler.SaveAction = Me.ResolveUrl("/Handlers/Scheduler_Save.ashx")
Scheduler.LoadData = True
Scheduler.EnableDataprocessor = True
I would like to find the possibility to set such a property to my own filepath, if possible ..
thx in advance

Further research showed me that I could change the default location with this line of code:
Scheduler.Codebase = "/js/dhtmlxscheduler"
However, this only sets the rootfolder, so all the files have to be located within this folder. I helped myself out by putting empty files over there and call my own styling and scripting from the location I wanted (just to get rid of the console errors).
So this solved my problem (as far as it could be solved).

Related

OpenFileDialog.InitialDirectory returns empty string instead of the path that opens in testing

I would like to point new users to the proper directory to where the file type may be found. However, I don't want to hamper the efficiency of experienced users, as there are more specific sub folders that they may wish to remain in throughout multiple file openings.
I found some context for openfileDialog for c++ here: Initial directory is not working for CFileDialog
However I am interested in a VB solution. Here is Microsoft's documentation:
https://msdn.microsoft.com/en-us/library/system.windows.forms.filedialog.initialdirectory(v=vs.110).aspx
in which they state
The InitialDirectory property is typically set using one of the following sources:
A path that was previously used in the program, perhaps retained from the last directory or file operation.
Here is my code:
If Not ImportDialog.InitialDirectory.Contains("Direct Access\Shell\Customer Invoices") Then
ImportDialog.InitialDirectory = "....\Direct Access\Shell\Customer Invoices\"
End If
How can I determine if a user would automatically be sent to this directory or a subdirectory in the tree if getting InitialDirectory is unreliable?
I saved the most recently opened folder and redirected the file path depending on if the user preferred a different path:
If _lastOpenFolder = "" Then
ImportDialog.InitialDirectory = "Direct Access\Shell\Customer Invoices\"
Else
ImportDialog.InitialDirectory = _lastOpenFolder
End If
If ImportDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
_lastOpenFolder = ImportDialog.FileName.Substring(0, ImportDialog.FileName.LastIndexOf("\"))
_lastOpenFolder = _lastOpenFolder.Substring(0, _lastOpenFolder.LastIndexOf("\"))
End If

an error 3013 thrown when writing a file Adobe AIR

I'm trying to write/create a JSON file from a AIR app, I'm trying not so show a 'Save as' dialogue box.
Here's the code I'm using:
var fileDetails:Object = CreativeMakerJSX.getFileDetails();
var fileName:String = String(fileDetails.data.filename);
var path:String = String(fileDetails.data.path);
var f:File = File.userDirectory.resolvePath( path );
var stream:FileStream = new FileStream();
stream.open(f, FileMode.WRITE );
stream.writeUTFBytes( jsonToExport );
stream.close();
The problem I'm having is that I get a 'Error 3013. File or directory in use'. The directory/path is gathered from a Creative Suite Extension I'm building, this path is the same as the FLA being developed in CS that the Extension is being used with.
So I'm not sure if the problem is that there are already files in the directory I'm writing the JSON file to?
Do I need to add a timer in order to close the stream after a slight delay, giving some time to writing the file?
Can you set up some trace() commands? I would need to know what the values of the String variables are, and the f.url.
Can you read from the file that you are trying to write to, or does nothing work?
Where is CreativeMakerJSX.getFileDetails() coming from? Is it giving you data about a file that is in use?
And from Googling around, this seems like it may be a bug. Try setting up a listener for when you are finished, if you have had the file open previously.
I re-wrote how the file was written, no longer running into this issue.

I can't get netbeans to find a txt file I have in the same directory... java.io.FileNotFoundException

I can't make it path specific because once I get this program to work (this is the last thing I have to do) I'm uploading to my university's ilearn website and it has to run on my professors computer with no modifications. I've tried a few different amalgamations of code similar to the following...
File file = new File("DataFile.txt");
Scanner document = new Scanner(new File("DataFile.txt"));
Or...
java.io.File file = new java.io.File("DataFile.txt");
Scanner document = new Scanner(file);
But nothing seems to work. I've got the necessary stuff imported. I've tried moving DataFile around in a few different folders (the src folder, and other random folders in the project's NetBeansProjects folder) I tried creating a folder in the project and putting the file in that folder and trying to use some kind of
documents/DataFile.txt
bit I found online (I named the folder documents).
I've tried renaming the file, saving it in different ways. I'm all out of ideas.
The file is just a list of numbers that are used in generating random data for this program we got assigned for building a gas station simulator. The program runs great when I just use user input from the console. But I can not get netbeans to find that file for the life of me! Help!?!?!?
Try adding the file to build path ..
public void readTextFile (){
try{
Scanner scFile =new Scanner(new File("filename.txt");
while(scFile.hasNext()){
String line =scFile.nextLine();
Scanner details=new Scanner(line).useDelimiter("symbol");
than you can work from there to store integer values use e.g in an array
litterArr(size)=details.nextInt();
Note: size is a variable counting the size/number of info the array has.
}
scFile.close();
{
catch
(FILENOTFOUNDEXCEPION e){
..... *code*
}
Keep file in the same folder as the program,but if it is saved in another folder you need to supply the path indicating the location of the file as part of the file name e.g memAthletics.Lines.LoadFromFile('C:\MyFiles\Athletics.txt');
hope this helps clear the problem up :)

Resolving relative paths outside the standard directories (applicationDirectory, desktopDirectory, etc)

I need to navigate to a file relative to my applicationDirectory, but as it says in the documentation:
No ".." reference that reaches the file system root or the application-persistent storage root passes that node; it is ignored.
But the crazy thing is that if I do something like
File.applicationDirectory.resolvePath("/home/myHome/");
I can get anywhere in the filesystem.
My question is:
is there a workaround to navigate from my applicationDirectory to a relative path like "../../my.cfg" ?? (I need to read a config file generated by a different application)
if you are trying to access root privileged folders - than you can not.
in other cases try do next "home/blah/blah/blah/../../my.cfg" and research once again http://help.adobe.com/en_US/AIR/1.5/jslr/flash/filesystem/File.html to save your time about navigation.
also you have another few ways: create a link to your file or run external bash/bat script.
I was previously using the little hack mentioned in Eugene's answer to copy from an absolute path:
var file = 'C:\Users\User1\Pictures\pic.png';
var newPath = air.File.applicationStorageDirectory.resolvePath('images/pic.png');
air.File.applicationDirectory.resolvePath('/../../../../../../../../../../' +
file).copyTo(newPath, true);
However, this is a much better way of doing it:
var file = 'C:\Users\User1\Pictures\pic.png';
var newPath = air.File.applicationStorageDirectory.resolvePath('images/pic.png');
new air.File(file).copyTo(newPath, true);

Executable directory where application is running from?

I need to get the path (not the executable) where my application is running from:
System.AppDomain.CurrentDomain.BaseDirectory()
When I run the above statement with & "/images/image.jpg" on my local machine it works fine but when I install the application on another machine it says it cannot find the file and there is a lot of extra path information some.
I just need the directory of where the app is running. I am coding in VB.NET with Visual Studio 2008.
Thanks!
This is the first post on google so I thought I'd post different ways that are available and how they compare. Unfortunately I can't figure out how to create a table here, so it's an image. The code for each is below the image using fully qualified names.
My.Application.Info.DirectoryPath
Environment.CurrentDirectory
System.Windows.Forms.Application.StartupPath
AppDomain.CurrentDomain.BaseDirectory
System.Reflection.Assembly.GetExecutingAssembly.Location
System.Reflection.Assembly.GetExecutingAssembly.CodeBase
New System.UriBuilder(System.Reflection.Assembly.GetExecutingAssembly.CodeBase)
Path.GetDirectoryName(Uri.UnescapeDataString((New System.UriBuilder(System.Reflection.Assembly.GetExecutingAssembly.CodeBase).Path)))
Uri.UnescapeDataString((New System.UriBuilder(System.Reflection.Assembly.GetExecutingAssembly.CodeBase).Path))
---
Edit October 18, 2021:
Sigh... None of the above work if using net5.0 or net6.0 and publishing app as single-file bundle. Best I got now is:
// This will give you the directory but not the assembly
string basedir = AppContext.BaseDirectory;
// Before you package the app as a single file bundle, you will get the dll.
// But after you publish it, you'll get the exe.
string pathToExecutable = Environment.GetCommandLineArgs()[0].Replace(".dll", ".exe");
Dim strPath As String = System.IO.Path.GetDirectoryName( _
System.Reflection.Assembly.GetExecutingAssembly().CodeBase)
Taken from HOW TO: Determine the Executing Application's Path (MSDN)
I needed to know this and came here, before I remembered the Environment class.
In case anyone else had this issue, just use this: Environment.CurrentDirectory.
Example:
Dim dataDirectory As String = String.Format("{0}\Data\", Environment.CurrentDirectory)
When run from Visual Studio in debug mode yeilds:
C:\Development\solution folder\application folder\bin\debug
This is the exact behaviour I needed, and its simple and straightforward enough.
Dim P As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)
P = New Uri(P).LocalPath
You could use the static StartupPath property of the Application class.
You can write the following:
Path.Combine(Path.GetParentDirectory(GetType(MyClass).Assembly.Location), "Images\image.jpg")