Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed Apr 03, 2019 12:45 pm

Hi,
I have some very strange issue.
I load and save workbook with:
(Workbook workbook = new Workbook();
if (File.Exists(fullPath))
{
myWorkbook.LoadFromFile(fullPath);
//... some calculations
myWorkbook.Save();
}
else
{
///...
}

The problem happens if workbook file exists in folder, but with different case. For example existing file name is "MyWorkBook.xlsx", but in variable fullPath it is myworkbook.xlsx. This happens on 2 of 5 client PCs, all tested PCs are with Win10 OS. When the bug happens, the result is totally unpredicted for me - in the folder there are both files MyWorkBook.xlsx and myworkbook.xlsx, but I cant open second one, it opens the first one :) It looks that this bug is combined with some windows bug :-D As I know, NTFS file names are case sensitive by design, but some internal windows components prevent this and make it case insensitive. So my suggestion is that the spire xls makes something that don't pass the windows check.

Of course, the workaround that I created is very simple, just check the file properties before open and see its windows name.

schernev
 
Posts: 4
Joined: Wed Apr 03, 2019 12:12 pm

Thu Apr 04, 2019 8:11 am

Hi,

Thanks for your inquiry.
I simulated your scenario and tested on several windows 10 systems, but didn't encounter the issue you described. The folder only has one Excel file named MyWorkBook.xlsx. Meanwhile, one thing puzzled me, if your system is case sensitive, when you load the file with name myworkbook.xlsx, the application should throw an exception --"the file could not be found". And as I know windows systems are case insensitive. Do you test your case on your other windows 10 systems? Is there a particular computer that doesn't have this strange behavior? If any, could you please do comparisons on your side and find out the setting differences between them?

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Mon Apr 08, 2019 11:12 am

" ...if your system is case sensitive,... "
NO, the systems ARE NOT case sensitive, that is the strange thing - how this thing could even happen in windows? (I wrote, that as I know for the NTFS file system, at low level the file system is case sensitive, but some higher level components try to prevent this and the OS presents it to the user as case insensitive file system. So, if you use some low level components for saving, just suggesting, it can trick somehow the OS)
About the second question - "This happens on 2 of 5 client PCs, all tested PCs are with Win10 OS"
And I can't see anything different in computer configurations.

schernev
 
Posts: 4
Joined: Wed Apr 03, 2019 12:12 pm

Tue Apr 09, 2019 9:13 am

Hi,

Thanks for your information.
The phenomenon is associated with some settings on your computer. And I got some information online that it is allowable for new versions of Windows 10 to treat files and folders as case sensitive. Maybe the folder in your computers which have the duplicate filename issue has enabled case sensitivity support. Please refer to the following documentations. Hope this could help you.
https://www.windowscentral.com/how-enable-ntfs-treat-folders-case-sensitive-windows-10
https://winaero.com/blog/enable-case-sensitive-mode-windows-10/

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Thu May 02, 2019 7:49 am

Hi, thanks for the reply.
The problem was resolved, it is not connected with Spire XLS. I put the workaround here, because it can help someone else.
The case sensitive conflict was because the folder was mapped as Google Drive folder, it looks it allowed case sensitive filenames (The local windows system don't allow this and this got more confusing to have the same files with different case).
So, this could happen when manipulating files no matter if the Spire.Xls is used. My workaround (C#):
Code: Select all
var folder = "c:\blahblah";
var fullPath =$"{folder}\MyFileName.xlsx";
var file = Directory.GetFiles(folder).FirstOrDefault(x => x.ToLower() == fullPath.ToLower()); // get first file in folder that equals fullPath in case insensitive way!
if (file != null)
{
    // open file
    myWorkbook.LoadFromFile(file);
    ...
}
else
{
    // create file
    ...
}

schernev
 
Posts: 4
Joined: Wed Apr 03, 2019 12:12 pm

Thu May 02, 2019 8:08 am

Hi,

Awesome :D .
Glad to hear that your issue has been resolved by yourself, you are so good.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.XLS