Filepath from excel to create a file don't works

Class library usage, coding and language questions.
ChrisN.
Posts: 33
Joined: Wed Jul 25, 2018 11:38 am
Location: Germany

Filepath from excel to create a file don't works

Post by ChrisN. » Thu Aug 23, 2018 9:18 am

Hello, I need some help in coding. I bound my Excel file and can read the tables, there are no Problems with it. But if I try to read a file path, which I writed in my cell, my script dont work corectly. The program must get the filepath(speicherort) from excel file and create a txt file in this path.
Some ideas?
Thanks
Ranorex 8.2.1
Windows 7

Image
Image
Last edited by ChrisN. on Wed Aug 29, 2018 7:49 am, edited 1 time in total.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Filepath from excel to create a file don't works

Post by odklizec » Thu Aug 23, 2018 9:43 am

Hi,

Try to write the path in excel without these characters... @" " and then use this:
string filePath = @varSpeicherort
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

ChrisN.
Posts: 33
Joined: Wed Jul 25, 2018 11:38 am
Location: Germany

Re: Filepath from excel to create a file don't works

Post by ChrisN. » Thu Aug 23, 2018 10:09 am

Thanks for the idea, but this didn't works.
this I see in the debug mode
Image

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Filepath from excel to create a file don't works

Post by odklizec » Thu Aug 23, 2018 1:29 pm

The reason why you see question marks in the console is that there is most probably enabled "Masking" for given (Speicherort) excel column.
https://www.ranorex.com/#Datamaskingoption
This means, that the content of masked value is not visible in console or report. However, it should not have any impact on the variable value in code. I would suggest to add a breakpoint at line string filePath = @varSpeicherort and examine the content of filePath in code. Also, make sure the format of excel cell is a plain text.

BTW, what error exactly are you getting? Are you sure you have a write access to the directory of your choice? If you are not logged as "zocnecae", you may not be able to write to his desktop. Try to write something to c:\temp or similar.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

ChrisN.
Posts: 33
Joined: Wed Jul 25, 2018 11:38 am
Location: Germany

Re: Filepath from excel to create a file don't works

Post by ChrisN. » Wed Aug 29, 2018 7:49 am

Thank you for the answer. I have the acces to the path and can write there.
I don't get any errors by execute the program, ranorex only don't create a file if I use a variable as path. If I write a path string in the script it works all. Both reports are the same.
Image

User avatar
RobinHood42
Posts: 324
Joined: Fri Jan 09, 2015 3:24 pm

Re: Filepath from excel to create a file don't works

Post by RobinHood42 » Wed Aug 29, 2018 2:36 pm

Hi ChrisN,

The value definitely gets resolved during the runtime, even if it's masked in the report:

RuntimeValue.png
Do you get any error messages when you try to create the file?

Cheers,
Robin
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Filepath from excel to create a file don't works

Post by odklizec » Wed Aug 29, 2018 7:31 pm

Hi,

In my opinion, there must be something wrong with the path stored in excel. I mean its format or maybe there are some non-printable leading/trailing characters in the path? Could you please share the excel file? Have you tried to debug the content of variable?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

ChrisN.
Posts: 33
Joined: Wed Jul 25, 2018 11:38 am
Location: Germany

Re: Filepath from excel to create a file don't works

Post by ChrisN. » Mon Sep 03, 2018 8:37 am

Hi, as first thank you for the interest and help. I don't know how to upload the excel file but I copy my file path and added it under this text. There are no any wrong characters in the string. I copied this directly from the place there you can add your formula.
I don't get any errors.
Somebody had the same problem in this forum but i can't find this post anymore. The post is 2-3 years old and not solved.

C:\Users\zocnecae\Desktop\Zeitstempel.txt

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Filepath from excel to create a file don't works

Post by odklizec » Mon Sep 03, 2018 9:42 am

Hi,

You can upload the file either via forum's attachments or simply use a public file sharing service (one drive, drop box, etc) and here post a link. I'm sure the key of the problem lies in the excel file.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

ChrisN.
Posts: 33
Joined: Wed Jul 25, 2018 11:38 am
Location: Germany

Re: Filepath from excel to create a file don't works

Post by ChrisN. » Mon Sep 03, 2018 10:06 am

Here is the link for the file.
https://www.dropbox.com/s/55fkj4blu1tmd ... .xlsx?dl=0
PS: I can read the path to open the file if its created but i cant use the path to create a file or write if its already created.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Filepath from excel to create a file don't works

Post by odklizec » Mon Sep 03, 2018 10:55 am

Hi,

There is definitely something wrong with the cell containing the path. If you try to edit the cell, there is a visible apostrophe character in front of the path? I tried to delete it, but it returns back. So I tried to copy the path from cell as a simple text and pasted it to below cell, and it copies without apostrophe.
excel.png
However, I tried your file and code on my system and it works as expected. The file is created and append without any problem. So my guess is that there is a problem with permission on your system? Try to write the file to "C:\temp", instead of using "user" desktop.
You do not have the required permissions to view the files attached to this post.
Last edited by odklizec on Mon Sep 03, 2018 1:14 pm, edited 1 time in total.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

ChrisN.
Posts: 33
Joined: Wed Jul 25, 2018 11:38 am
Location: Germany

Re: Filepath from excel to create a file don't works

Post by ChrisN. » Mon Sep 03, 2018 12:57 pm

Thank you very much, this was a part of the problem. It works now in my usercode. I try now to use this code in external file and call this file in my usercode. By this i have a same problem like bevor but its a question of C#.
Thank you all.