Thread: [RESOLVED] "Run time error ’52’: Bad file name or number" when i open associated text file
Addicted Member
Join Date Dec 2009 Location B.C. Canada Posts 206
[RESOLVED] "Run time error ’52’: Bad file name or number" when i open associated text file
i am getting error "Run time error ’52’: Bad file name or number" when i use this code to open a text file that is accociated with my app.
File association is set up using inno.
when i replace Command$ with "C:\Users\Dave\Documents\dave.cppl" and run it in design mode there is no error.
- View Profile
- View Forum Posts
PowerPoster
Join Date Mar 2004 Location New Amsterdam Posts 24,132
Re: "Run time error ’52’: Bad file name or number" when i open associated text file
- View Profile
- View Forum Posts
- Visit Homepage
Addicted Member
Join Date Dec 2009 Location B.C. Canada Posts 206
Re: "Run time error ’52’: Bad file name or number" when i open associated text file
DoubleClickedFile = Mid(DoubleClickedFile, 4, Len(DoubleClickedFile) — 3)
returns this: \Users\Dave\Documents\dave.cppl"
and DoubleClickedFile returns this: "C:\Users\Dave\Documents\dave.cppl"
i was trying to remove the drive letter but did nit remove the right side quote marks.
Does the drive letter need to be removed of this to work?
- View Profile
- View Forum Posts
Super Moderator
Join Date Jul 2002 Location Bristol, UK Posts 41,815
Re: "Run time error ’52’: Bad file name or number" when i open associated text file
Why are you trying to remove the drive letter?
That is an important part of the file location, and as you are opening the file you want to know the full file location.
- View Profile
- View Forum Posts
- Visit Homepage
Addicted Member
Join Date Dec 2009 Location B.C. Canada Posts 206
Re: "Run time error ’52’: Bad file name or number" when i open associated text file
- View Profile
- View Forum Posts
PowerPoster
Join Date Mar 2004 Location New Amsterdam Posts 24,132
Re: "Run time error ’52’: Bad file name or number" when i open associated text file
- View Profile
- View Forum Posts
Super Moderator
Join Date Jul 2002 Location Bristol, UK Posts 41,815
Re: "Run time error ’52’: Bad file name or number" when i open associated text file
I can’t think of any situation like this where removing the drive letter would be a good thing.
Does Command$ actually contain the " character at the start and end?
If so, this should solve it:
- View Profile
- View Forum Posts
- Visit Homepage
Addicted Member
Join Date Dec 2009 Location B.C. Canada Posts 206
Re: "Run time error ’52’: Bad file name or number" when i open associated text file
- View Profile
- View Forum Posts
Super Moderator
Join Date Jul 2002 Location Bristol, UK Posts 41,815
Re: "Run time error ’52’: Bad file name or number" when i open associated text file
- View Profile
- View Forum Posts
- Visit Homepage
Addicted Member
Join Date Dec 2009 Location B.C. Canada Posts 206
Re: "Run time error ’52’: Bad file name or number" when i open associated text file
- Site Areas
- Forums
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
is On are On code is On code is On
- HTML code is Off
Click Here to Expand Forum to Full Width
Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.
помогите пожалуйста у меня постоянна выходит это ошибка (run-time error ’52’:Bad file or namber) как мне исправить её?
http://www.fixerror.net/2009/07/fix-runtime-error-52-for-internet-explorer/
—
In Internet Explorer runtime error 52 appear when the script (JavaScript) cannot find a file and is more likely a connectivity problem.
To fix this error you should clear your temporary internet files, and if the problem persists you should contact the administrator of the website.
—
Если тяжко с английским — могу перевести
run time error 52 bad file name or number как исправить
При попытке доступа к заданному файлу возникла ошибка. Эта ошибка имеет следующие причины и способы решения:
Оператор ссылается на файл с номером файла или именем файла, которые:
Не определены в операторе Open либо был определен в операторе Open, но с тех пор закрыт. Укажите имя файла в операторе Open. Обратите внимание, что если оператор Close выполнить без аргументов, возможно, все открытые в текущий момент файлы будут ненамеренно закрыты, тем самым сделав недействительными все номера файлов.
За пределами диапазона номеров файлов (1–511). Если кодом генерируются номера файлов по алгоритму, убедитесь, что номера являются допустимыми.
Существует недопустимое имя или недействительный номер.
Имена файлов должны соответствовать соглашениям, принятым в операционной системе, а также соглашениям по именованию файлов в языке Basic.
В Microsoft Windows используются следующие соглашения по именованию файлов и каталогов:
Имя файла или каталога может состоять из двух частей: имени и необязательного расширения. Две части разделяются точкой, например, myfile.new.
Имя может содержать до 255 знаков включительно.
Имя должно начинаться с буквы или цифры. Оно может содержать любые прописные или строчные знаки (имена файлов не чувствительны к регистру клавиатуры): кавычки («), апостроф (‘), косую черту (/), обратную косую черту (**), двоеточие (:) и вертикальную черту (|**).
Имя может содержать пробелы.
Следующие имена зарезервированы и не могут использоваться для файлов и каталогов: CON, AUX, COM1, COM2, COM3, COM4, LPT1, LPT2, LPT3, PRN и NUL. Например, если попытаться присвоить файлу имя PRN в операторе Open, принтер по умолчанию просто станет адресатом для операторов Print # и Write #, направляемых в номер файла, который указывается в операторе Open.
На компьютерах Macintosh имя файла может включать любой знак за исключением двоеточия (:), а также может содержать пробелы. Использование символов Null (Chr(0)) в именах файлов не допускается.
Для получения дополнительной информации выберите необходимый элемент и нажмите клавишу F1 (для Windows) или HELP (для Macintosh).
Поддержка и обратная связь
Есть вопросы или отзывы, касающиеся Office VBA или этой статьи? Руководство по другим способам получения поддержки и отправки отзывов см. в статье Поддержка Office VBA и обратная связь.
Как исправить ошибку 52 (cc2BadFileNameOrNumber)
| Номер ошибки: | Ошибка 52 |
| Название ошибки: | cc2BadFileNameOrNumber |
| Описание ошибки: | Bad file name or number. |
| Разработчик: | Microsoft Corporation |
| Программное обеспечение: | Windows Operating System |
| Относится к: | Windows XP, Vista, 7, 8, 10, 11 |
Классические проблемы Cc2BadFileNameOrNumber
В первую очередь ошибки cc2BadFileNameOrNumber относятся к отсутствующему или поврежденному файлу cc2BadFileNameOrNumber. Это 9 основных ошибок, которые видны в Windows:
Эти сообщения об ошибках Windows 10 могут появляться во время установки программы, в то время как программа, связанная с cc2BadFileNameOrNumber (например, 52) работает, во время запуска или завершения работы Windows, или даже во время установки операционной системы Windows.
Причины проблем Cc2BadFileNameOrNumber
Шансы на ошибки и манипуляции cc2BadFileNameOrNumber высоки с этими внешними файлами. Файлы cc2BadFileNameOrNumber повреждены от вредоносных программ, плохих отключений (ОС или 52) и других сценариев, связанных с ActiveX. После повреждения cc2BadFileNameOrNumber не может загрузиться, вызывая проблемы при запуске соответствующего программного обеспечения.
В других случаях проблемы реестра с cc2BadFileNameOrNumber могут быть источником проблемы ActiveX. Эти проблемы с регистрацией cc2BadFileNameOrNumber связаны с сломанными ссылками на DLL-файлы. Оставшиеся разделы реестра 52 или cc2BadFileNameOrNumber, перемещенные или отсутствующие cc2BadFileNameOrNumber, плохие установки или удаления, могут нарушить ссылки на пути к файлам cc2BadFileNameOrNumber.
В частности, проблемы cc2BadFileNameOrNumber возникают с:
Совместима с Windows 2000, XP, Vista, 7, 8, 10 и 11
Bad file name or number (Error 52)
An error occurred trying to access the specified file. This error has the following causes and solutions:
A statement refers to a file with a file number or file name that is:
Not specified in the Open statement or was specified in an Open statement, but has since been closed. Specify the file name in an Open statement. Note that if you invoked the Close statement withoutarguments, you may have inadvertently closed all currently open files, invalidating all file numbers.
There is an invalid name or number.
File names must conform to operating system conventions as well as Basic file-naming conventions.
In Microsoft Windows, use the following conventions for naming files and directories:
The name of a file or directory can have two parts: a name and an optional extension. The two parts are separated by a period, for example, myfile.new.
The name can contain up to 255 characters.
The name must start with either a letter or number. It can contain any uppercase or lowercase characters (file names aren’t case-sensitive) except the following characters: quotation mark («), apostrophe (‘), slash (/), backslash (**), colon (:), and vertical bar (|**).
The name can contain spaces.
The following names are reserved and can’t be used for files or directories: CON, AUX, COM1, COM2, COM3, COM4, LPT1, LPT2, LPT3, PRN, and NUL. For example, if you try to name a file PRN in an Open statement, the default printer will simply become the destination for Print # and Write # statements directed to the file number specified in the Open statement.
On the Macintosh, a file name can include any character except the colon (:), and can contain spaces. Null characters (Chr(0)) aren’t allowed in any file names.
For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Run time error 52 bad file name or number как исправить
Пишу в файл произволного доступа:
Private Sub SaveToFile( ByVal Patth As String )
‘ïèøåì ôàéë äàííûõ
Dim Fl As Integer
Fl = FreeFile
Open Patth For Random As #Fl Len = Len (kk(1, 1))
If Grid1.TextArray(Grid1.GetCellIndex(i, j)) = «» Then _
Grid1.TextArray(Grid1.GetCellIndex(i, j)) = «0»
kk(i, j) = Grid1.TextArray(Grid1.GetCellIndex(i, j))
k = k + 1
Put #Fl, k, kk(i, j)
Next j
Next i
но если обращаюсь во:
MsgBox Command ‘for check
Call SaveToFile(Command)
Собственно, к такому же выводу пришел и гугл:
http://support.microsoft.com/kb/214674
причина вроде ясна, но как ее обойти, я не нашел
Как правильно выйти из этой ситуации?
| Ответы | Всего ответов: 15 |
| Номер ответа: 1 Автор ответа: Виктор M но если обращаюсь во: когда открываю программу через какой-то файл и передаю в качестве параметра значение коммандной строки, то появляется ошибка: Раз путь к файлу верный, номер файла по всем правилам не может быть занят, так как получен из Freefile, то возможно что этот файл уже открыт. а возможно я заблуждаюсь, но тогда в чем причина? Private Sub Form_Load() .row = 0 .TextArray(.GetCellIndex(0, 0)) = «Íîìåð ðåæèìà» .TextArray(.GetCellIndex(0, 0)) = «Íîìåð ðåæèìà» ‘÷èòàåì èç ôàéëà äàííûõ For i = 1 To 4 Спасибо, shuffle, ты молодец! How to fix the Runtime Error 52 Bad file name or numberThis article features error number Code 52, commonly known as Bad file name or number described as An error occurred trying to access the specified file. Error InformationError name: Bad file name or number This repair tool can fix common computer errors like BSODs, system freezes and crashes. It can replace missing operating system files and DLLs, remove malware and fix the damage caused by it, as well as optimize your PC for maximum performance. About Runtime Error 52Runtime Error 52 happens when Windows fails or crashes whilst it’s running, hence its name. It doesn’t necessarily mean that the code was corrupt in some way, but just that it did not work during its run-time. This kind of error will appear as an annoying notification on your screen unless handled and corrected. Here are symptoms, causes and ways to troubleshoot the problem. Definitions (Beta)Here we list some definitions for the words contained in your error, in an attempt to help you understand your problem. This is a work in progress, so sometimes we might define the word incorrectly, so feel free to skip this section! Runtime errors happen without warning. The error message can come up the screen anytime Windows is run. In fact, the error message or some other dialogue box can come up again and again if not addressed early on. There may be instances of files deletion or new files appearing. Though this symptom is largely due to virus infection, it can be attributed as a symptom for runtime error, as virus infection is one of the causes for runtime error. User may also experience a sudden drop in internet connection speed, yet again, this is not always the case. During software design, programmers code anticipating the occurrence of errors. However, there are no perfect designs, as errors can be expected even with the best program design. Glitches can happen during runtime if a certain error is not experienced and addressed during design and testing. Runtime errors are generally caused by incompatible programs running at the same time. It may also occur because of memory problem, a bad graphics driver or virus infection. Whatever the case may be, the problem must be resolved immediately to avoid further problems. Here are ways to remedy the error. Repair MethodsRuntime errors may be annoying and persistent, but it is not totally hopeless, repairs are available. Here are ways to do it. If a repair method works for you, please click the upvote button to the left of the answer, this will let other users know which repair method is currently working the best. |
